<jupyter_start><jupyter_text>Pandas for Data Science [Pandas Documentation](https://pandas.pydata.org/)<jupyter_code>import pandas as pd
print(pd)
df = pd.read_csv('/home/martin/datasets/flights.csv')
df.head()
df.describe()
df.isnull()
df.isnull().sum()
df = df.drop(['year', 'month', 'day', 'dep_time', 'arr_time', 'flight', 'tailnum', 'air_time',
              'distance', 'hour', 'minute', 'time_hour'], axis=1)
df.head()
pd.value_counts(df['carrier'])
pd.value_counts(df['carrier']).plot.bar()
df.groupby('carrier').mean()
df.groupby('carrier').mean()['dep_delay']
# This will cause an error
df.groupby('carrier').mean()['dep_delay', 'arr_delay']
df.groupby('carrier').mean()[['dep_delay', 'arr_delay']]
df.groupby('carrier').mean()[['dep_delay', 'arr_delay']].plot.bar()
df['route'] = df['origin'] + ' - ' + df['dest']
df.head()
df['schedule_flight_time'] = df['sched_arr_time'] - df['sched_dep_time']
df.head()
df.groupby(['route', 'carrier']).mean()
df.groupby(['route', 'carrier']).mean()[:50]
df.sort_values('dep_delay')
df.dropna(subset=['dep_delay']).sort_values('dep_delay')
df.dropna(subset=['dep_delay']).sort_values('dep_delay', ascending=False)
df.dropna(subset=['dep_delay']).sort_values(['carrier', 'dep_delay'])<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup