Instantly share code, notes, and snippets.
Wonderful notebook! Helps me know R better. There might be something that will help others know pandas better.
Anyway, as in In, flights.iloc[:9] is fine. But wouldn't flights.loc[:10] be more equivalent?
# select(flights, year:day)
# No real equivalent here. Although I think this is OK.
# Typically I'll have the columns I want stored in a list
# somewhere, which can be passed right into __getitem__ ().
I'm only guessing what the R code does, but how about flights.loc[:, 'year':'day'] ? And if there's a list of columns to get, named columns for example, I think flights[columns] will do, other than __getitem__ ().
# select(flights, -(year:day))
If I'm guessing right, flights.loc[:, ~flight.columns.isin(a.loc[:, 'year':'day'])] might do. But it's a little bit tedious and less elegant than R.
flights.loc[:, ~flight.columns.isin(a.loc[:, 'year':'day'])]
Again, a very helpful notebook.
Sorry, something went wrong.
For those who are struggling to translate your R code into python, you might want to take a look at this package:
which reimages pandas APIs and aligns them with tidyverse's.