Everyone is welcome here --- except those who have borrowed books from me for and have not returned them yet!

Cheat sheet for pandas

Posted on July 01, 2016 in computer-science

See https://pandas.pydata.org/pandas-docs/stable/getting_started/10min.html

import pandas as pd

Creating a DataFrame:

  • from a csv file:

    example = pd.read_csv('filename.csv')
  • from columns, that is from a dictionney associating labesl (column names) to pd.Series)

    ex = pd.DataFrame(dict(col1=pd.Series([1, 2, np.nan, 5)]),
                           col2=pd.Series([1, 2, np.nan, 5)]),