Skip to content

Instantly share code, notes, and snippets.

@bitliner
Last active October 4, 2024 14:07
Show Gist options
  • Save bitliner/217f4162ad4160cd7c969ea73fdc591c to your computer and use it in GitHub Desktop.
Save bitliner/217f4162ad4160cd7c969ea73fdc591c to your computer and use it in GitHub Desktop.

pandas

add column

tutors = ['William', 'Henry', 'Michael', 'John', 'Messi']
df2 = df.assign(TutorsAssigned=tutors)

OR

df2=df.assign(Discount_Percent=lambda x: x.Fee * x.Discount / 100)

filter rows

df[df.apply(lambda x: x['b'] > x['c'], axis=1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment