Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main page example flights.groupby(['year', 'month', 'day']) using pandas only #11

Open
paulrougieux opened this issue Dec 16, 2019 · 1 comment

Comments

@paulrougieux
Copy link

The main example in the readme could be re-written as such using only pandas:

import pandas
flights = pandas.read_csv('~/downloads/flights.csv')
df = (flights
      .groupby(['year', 'month', 'day'])
      .agg({'arr_delay': 'mean',
            'dep_delay': 'mean'})
      .query("arr_delay>30 & dep_delay>30")
     )

Note I exported the flights data set from R with

library(nycflights13)
write.csv(flights,"~/downloads/flights.csv",` row.names=FALSE)
@paulrougieux paulrougieux changed the title Main page example flights.groupby(['year', 'month', 'day']) Main page example flights.groupby(['year', 'month', 'day']) Dec 16, 2019
@paulrougieux paulrougieux changed the title Main page example flights.groupby(['year', 'month', 'day']) Main page example flights.groupby(['year', 'month', 'day']) using pandas only Dec 16, 2019
@paulrougieux
Copy link
Author

You can obviously add a rename with :

df.rename(columns={'arr_delay':'arr','dep_delay':'dep'})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant