Welcome to P y thon ! P YTH ON FOR SP R E AD SH E E T U SE R S Chris Cardillo Data Scientist
What is P y thon ? General p u rpose programming lang u age Has code packages for data science Object - oriented PYTHON FOR SPREADSHEET USERS
Object - oriented spreadsheets PYTHON FOR SPREADSHEET USERS
Object - oriented spreadsheets PYTHON FOR SPREADSHEET USERS
Object - oriented P y thon In P y thon In Spreadsheets math.SUM(2,3) PYTHON FOR SPREADSHEET USERS
The po w er of the dot math is o u r package math.SUM() SUM is o u r f u nction in the package The dot ( . ) lets u s access the f u nction inside the package PYTHON FOR SPREADSHEET USERS
Scripts A Recipe for B u � ered Toast 1. Turn on toaster 2. Put bread in toaster for 1 minute 3. Take bread out of toaster 4. Put butter on toast PYTHON FOR SPREADSHEET USERS
Importing packages import math PYTHON FOR SPREADSHEET USERS
Importing pandas PYTHON FOR SPREADSHEET USERS
Importing pandas import pandas PYTHON FOR SPREADSHEET USERS
Loading E x cel data import pandas pandas.read_excel('fruit.xlsx') fr u it .x ls x ( the kind of data pandas likes ) PYTHON FOR SPREADSHEET USERS
pandas as pd before a � er import pandas import pandas as pd pandas.read_excel('fruit.xlsx') pd.read_excel('fruit.xlsx') PYTHON FOR SPREADSHEET USERS
Variable assignment import pandas as pd fruit = pd.read_excel('fruit.xlsx') fr u it .x ls x PYTHON FOR SPREADSHEET USERS
Looking at data w ith print () import pandas as pd fruit = pd.read_excel('fruit.xlsx') print(fruit) PYTHON FOR SPREADSHEET USERS
Script and console panes in DataCamp SCRIPT.PY is the script IPYTHON SHELL is the console PYTHON FOR SPREADSHEET USERS
Yo u r t u rn ! P YTH ON FOR SP R E AD SH E E T U SE R S
DataFrames and their methods P YTH ON FOR SP R E AD SH E E T U SE R S Chris Cardillo Data Scientist
Where w e left off import pandas as pd fruit = pd.read_excel('fruit.xlsx') print(fruit) PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
Anatom y of a pandas DataFrame PYTHON FOR SPREADSHEET USERS
DataFrame methods .head() .info() .describe() .sort_values() PYTHON FOR SPREADSHEET USERS
The . head () method import pandas as pd fruit = pd.read_excel('fruit.xlsx') print(fruit.head()) PYTHON FOR SPREADSHEET USERS
The . head () method import pandas as pd fruit = pd.read_excel('fruit.xlsx') print(fruit.head(2)) PYTHON FOR SPREADSHEET USERS
The . info () method import pandas as pd fruit = pd.read_excel('fruit.xlsx') print(fruit.info()) PYTHON FOR SPREADSHEET USERS
The . describe () method import pandas as pd fruit = pd.read_excel('fruit.xlsx') print(fruit.describe()) PYTHON FOR SPREADSHEET USERS
The . sort _v al u es () method import pandas as pd fruit = pd.read_excel('fruit.xlsx') fruit = fruit.sort_values('name') fruit = fruit.reset_index(drop=True) print(fruit) PYTHON FOR SPREADSHEET USERS
The . sort _v al u es () method import pandas as pd fruit = pd.read_excel('fruit.xlsx') fruit = fruit.sort_values('price_usd', ascending=False) fruit = fruit.reset_index(drop=True) print(fruit.head(3)) PYTHON FOR SPREADSHEET USERS
Yo u r t u rn ! P YTH ON FOR SP R E AD SH E E T U SE R S
Filtering ro w s and creating col u mns P YTH ON FOR SP R E AD SH E E T U SE R S Chris Cardillo Data Scientist
Filtering in spreadsheets PYTHON FOR SPREADSHEET USERS
Accessing a single col u mn PYTHON FOR SPREADSHEET USERS
Accessing a single col u mn fruit['name'] PYTHON FOR SPREADSHEET USERS
Comparison operators == ( eq u al to ) != ( not eq u al to ) < ( less than ) > ( greater than ) <= ( less than or eq u al to ) >= ( greater or eq u al to ) PYTHON FOR SPREADSHEET USERS
Comparisons fruit['name'] fruit['name'] == "Apple" PYTHON FOR SPREADSHEET USERS
Filtering fruit[fruit['name'] == "Apple"] PYTHON FOR SPREADSHEET USERS
Filtering fruit[fruit['price_usd'] > 1] PYTHON FOR SPREADSHEET USERS
Filtering fruit[fruit['price_usd'] > 1].reset_index(drop=True) PYTHON FOR SPREADSHEET USERS
Basic filtering pattern df[df['this_column'] == 'that value'] PYTHON FOR SPREADSHEET USERS
Basic filtering pattern In P y thon In Spreadsheets fruit[fruit['name'] == "Apple"] PYTHON FOR SPREADSHEET USERS
Creating a ne w col u mn PYTHON FOR SPREADSHEET USERS
Creating a ne w col u mn PYTHON FOR SPREADSHEET USERS
Mathematical operators + ( addition ) - ( s u btraction ) * ( m u ltiplication ) / ( di v ision ) PYTHON FOR SPREADSHEET USERS
Creating a ne w col u mn fruit['cost'] = fruit['price_usd'] * 2 PYTHON FOR SPREADSHEET USERS
Creating a ne w col u mn PYTHON FOR SPREADSHEET USERS
Creating a ne w col u mn PYTHON FOR SPREADSHEET USERS
Creating a ne w col u mn fruit['cost'] = fruit['price_usd'] * fruit['quantity'] PYTHON FOR SPREADSHEET USERS
Yo u r t u rn ! P YTH ON FOR SP R E AD SH E E T U SE R S
Recommend
More recommend