pandas

pandas is a Python library for data manipulation and analysis.

Panda Eating Bamboo

Libaries

Notes

Snippets

Connect to a SQLite database

Using a SQLAlchemy engine to connect to a database

Python compatible column names with slugify

Usually I'm dealing with data from external sources that don't have pretty columns names. I like to use slugifyarrow-up-right to convert them to Python compatible keys.

Read CSV file with all cells as strings

Traspose DataFrame and view all rows

Convert a column from continuous to categorical

Kevin Markham (justmarkhamarrow-up-right) - https://twitter.com/justmarkham/status/1146040449678925824arrow-up-right

Read a CSV file data in chunk size

Sometimes a CSV is just to large for the memory on your computer. You can tell the argument chunksize how many rows of data you would like to load.

If you would like to load the scale down the data and load the it into one pd.DataFrame:

Pandas/SQL Rosetta Stone

IN / pandas.DataFrame.isin

See the pandas documentation for more information on pandas.DataFrame.isinarrow-up-right.

Last updated