Code 401 Class 12 Reading Notes
Pandas in 10
MORE TO ADD HERE
What is Pandas
‘If it involves data analysis with python, your going to want to use pandas’ ~Python Programmer
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
Create a variable to read a file type.
Example:
titanic_df = pd.read_excel(‘titanic3.xls’,titanic3’, index_col = None, na_values=[‘NA’])
titanic_df.head()
To get rid of columns
Example:
titanic_df.drop([‘ticket’,’cabin’,’boat’,’body’],axis=1).head()
To do a plot.
Example
pd.value_counts(titanic_df[‘survived’]).plot.bar()
Group data by columns and filter by age:
Example
titanic_df[titanic_df[‘age’]<18].groupby([‘sex’,’pclass’]).mean()
Creating a plot graph:
Example
%matplotlib inline ms.head()
ms[‘Adj. Close’].plot()