Python with Pandas: DataFrame Tutorial with Examples
Introduction
Pandas is an open-source Python library for data analysis. It is designed for efficient and intuitive handling and processing of structured data.
The two main data structures in Pandas are Series
and DataFrame
. Series
are essentially one-dimensional labeled arrays of any type of data, while DataFrame
s are two-dimensional, with potentially heterogenous data types, labeled arrays of any type of data. Heterogenous means that not all “rows” need to be of equal size.
In this article we will go through the most common ways of creating a DataFrame
and methods to change their structure.
We’ll be using the Jupyter Notebook since it offers a nice visual representation of DataFrame
s. Though, any IDE will also do the job, just by calling a print()
statement on the DataFrame
object.
Creating DataFrames
Whenever you create a DataFrame
, whether you’re creating one manually or generating one from a datasource such as