Author : MD TAREQ HASSAN | Updated : 2023/07/20

What is Dataframe?

Components

Overview

Pandas Dataframe overview Step 1

Pandas Dataframe overview Step 2

Accessing series

Syntax 1: dataframe['SeriesName']
Syntax 2: dataframe.SeriesName

import pandas as pd

# dataframe
df = pd.read_csv("foo.csv")

Single series

df["bar"]

Multiple series

df[ ["baz", "bax"] ]    # returns Dataframe

Sub-dataframe

import pandas as pd

# dataframe
df = pd.read_csv("foo.csv")

# sub-dataframe from dataframe
subdf = df[ ["Bar", "Baz"] ]

type(subdf)    # pandas.core.frame.DataFrame

Shape

import pandas as pd
df = pd.read_csv("foo.csv")

shape = df.shape

rowCount = shape[0]
colCount = shape[1]

print(f"rowCount: {rowCount}")
print(f"colCount: {colCount}")

Head and tail

Info