Basics
Pandas is Python’s module for working with tabular data (data that has rows and columns). Pandas gives you the functionality of programs like SQL or Excel along with all the power of Python.
To use the package, we usually import it at the top of a Python file under the alias pd.
import pandas as pdIn pandas, the two major data structures are Series and DataFrame.
df = pd.DataFrame([
['January', 100, 100, 23, 100],
['February', 51, 45, 145, 45],
['March', 81, 96, 65, 96],
['April', 80, 80, 54, 180],
['May', 51, 54, 54, 154],
['June', 112, 109, 79, 129]],
columns=['month', 'clinic_east',
'clinic_north', 'clinic_south',
'clinic_west']
)
clinic_north = df.clinic_north
print(type(clinic_north))
# <class 'pandas.core.series.Series'>
print(type(df))
# <class 'pandas.core.frame.DataFrame'>Series
A Series is a one-dimensional array-like object containing an array of data (of any NumPy data type) and an associated array of data labels, called its index .
Another way to think about a Series is as a fixed-length, ordered dict, as it is a mapping of index values to data values.
Last updated
Was this helpful?