Skip to content

Instantly share code, notes, and snippets.

@leleofg
Created February 1, 2018 02:46
Show Gist options
  • Select an option

  • Save leleofg/9ceafa8480526cf29b8c5dfde5876dc8 to your computer and use it in GitHub Desktop.

Select an option

Save leleofg/9ceafa8480526cf29b8c5dfde5876dc8 to your computer and use it in GitHub Desktop.
Pandas Discount
import pandas as pd
purchase_1 = pd.Series({'Name': 'Chris',
'Item Purchased': 'Dog Food',
'Cost': 22.50})
purchase_2 = pd.Series({'Name': 'Kevyn',
'Item Purchased': 'Kitty Litter',
'Cost': 2.50})
purchase_3 = pd.Series({'Name': 'Vinod',
'Item Purchased': 'Bird Seed',
'Cost': 5.00})
df = pd.DataFrame([purchase_1, purchase_2, purchase_3], index=['Store 1', 'Store 1', 'Store 2'])
df['Cost'] *= 0.8
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment