Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 29, 2020 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/2a936912e69e243238b177108eada358 to your computer and use it in GitHub Desktop.
Save codecademydev/2a936912e69e243238b177108eada358 to your computer and use it in GitHub Desktop.
Codecademy export
import codecademylib
import pandas as pd
inventory = pd.read_csv('inventory.csv')
inventory.head(10)
staten_island = inventory[0:10]
print(staten_island)
product_request = staten_island.product_description
print(product_request)
seed_request = inventory[(inventory.location == 'Brooklyn') & (inventory.product_type == 'seeds')]
print(seed_request)
inventory['in_stock'] = inventory.apply(lambda x: True if x['quantity'] > 0 else False, axis = 1)
print(inventory.head())
inventory['total_value'] = inventory.apply(lambda x: x.price * x.quantity, axis = 1)
print(inventory.head())
combine_lambda = lambda row: \
'{} - {}'.format(row.product_type,
row.product_description)
inventory['full_discription'] = inventory.apply(lambda x: (x.product_type, x.product_description), axis = 1)
print(inventory.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment