Know Python Pandas series methods? You already know data frame methods! Same methods, applied column-wise!
Reading a multi-sheet Excel file into Python Pandas? Ask for a specific sheet by name or index: Get a dict of data frames with specific sheets:
How much memory does a text column in your Python Pandas data frame use? Check: But this is likely a huge underestimate! It sums the pointer sizes, not the string sizes. Instead, say: Or:
Want to turn an online CSV file into a Python Pandas data frame? Just pass a URL to read_csv: Options such as usecols and index_col work! This works on all read_* methods, including read_excel, read_json, and read_parquet.
After plotting a Python Pandas data frame in Jupyter, how do you save it to a file?
If your Python Pandas dataframe has a datetime index, use a slice to retrieve rows in a certain time period: But if the rows are unsorted? You get a KeyError. Solution:
Retrieve rows of a Python Pandas data frame with the 6 largest values of column x: Even better: Why is it better? On a 3m row, 680 MB data frame, sort/tail took 622 ms. nlargest? Only 84 ms — 7x faster!
A Python Pandas rule of thumb: Wherever you can use a column name (string), you can use multiple column names (a list of strings):
To sort a Python Pandas data frame by column x: By x and y (ascending): By x and y, both descending: Ascending x, descending y:
Need specific column types in Python Pandas? Use select_dtypes: