Skip to content

Instantly share code, notes, and snippets.

@debidatta
Created May 6, 2015 09:52
Show Gist options
  • Select an option

  • Save debidatta/6d2f6ad1f9b47910e2ee to your computer and use it in GitHub Desktop.

Select an option

Save debidatta/6d2f6ad1f9b47910e2ee to your computer and use it in GitHub Desktop.
Custom filtering and mapping in Pandas
# mapped_series = df['series'].map(lambda x: Value you want x to be mapped to]
mapped_series = df['series'].map(lambda x: x**2)
# filtered_df = df['series'].map(lambda x: True/False function]
filtered_df = df[df['series'].map(lambda x: len(x)>3]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment