2024-heraklion-data/notebooks/030_tabular_data/011_pandas_introduction_tutor.ipynb
2024-08-27 15:27:53 +03:00

5.5 KiB

Pandas, quick introduction

In [1]:
import pandas as pd

Pandas introduces a tabular data structure, the DataFrame

  • Columns can be of any C-native type
  • Columns and rows have indices, i.e. labels that identify each column or row
In [2]:
df = pd.DataFrame(
    data = [
        ['Anthony', 28, 1.53], 
        ['Maria', 31, 1.76], 
        ['Emma', 26, 1.83], 
        ['Philip', 41, 1.81], 
        ['Bill', 27, None],
    ],
    columns = ['name', 'age', 'height'],
    index=['A484', 'C012', 'A123', 'B663', 'A377'],
)
In [ ]:
df
In [ ]:

In [ ]:

DataFrame attributes

In [ ]:

In [ ]:

Indexing rows and columns

In [ ]:

In [ ]:

In [ ]:

Examining a column

In [ ]:

In [ ]:

Filtering

In [ ]:

In [ ]:

Basic operations are by column (unlike NumPy)

In [ ]:

In [ ]:

In [ ]:

In [ ]:

Operations on strings

In [ ]:

In [ ]:

In [ ]:

In [ ]:

Adding new columns

In [ ]:

In [ ]:

In [ ]: