DataFrame

Learn about the pandas DataFrame object for 2-D data.

Chapter Goals:

  • Learn about the pandas DataFrame object and its basic utilities
  • Write code to create and manipulate a pandas DataFrame

A. 2-D data

One of the main purposes of pandas is to deal with tabular data, i.e. data that comes from tables or spreadsheets. Since tabular data contains rows and columns, it is 2-D. For working with 2-D data, we use the pandas.DataFrame object, which we'll refer to simply as a DataFrame.

A DataFrame is created through the pd.DataFrame constructor, which takes in essentially the same arguments as pd.Series. However, while a Series could be constructed from a scalar (representing a single value Series), a DataFrame cannot.

Furthermore, pd.DataFrame takes in an additional columns keyword argument, which represents the labels ...