# Libraries
import pandas as pd
# Dataframe created from a dictionary
data1 = {
"col1":[1,2,3,4,5,6,7,8,9,10],
"col2":[11,12,13,14,15,16,17,18,19,20]
}
df = pd.DataFrame(data = data1)
print(df)
# shape method help us to know the dimension of the df
df.shape
df.shape[0]
df.shape[1]
# row*col
df.size
df.ndim
# Dataframe created from a dictionary
data2 = {
"col1":[1,2,3,4,5,6,7,8],
"col2":[11,12,13,14,15,16,17,18],
"col3":["Car","Bike","Train","Plane","Ship","Aircraft","Mountain Bike","Scooter"],
"col4":[True, False,True, False,True, False,True, False]
}
df = pd.DataFrame(data = data2)
print(df)
print(df.set_index("col3"))
# the first 5 observations
print(df.head())
# the first 3 observations
#print(df.head(3))
# the last 5 observations
print(df.tail())
# the last 2 observations
#print(df.tail(2))
df1 = df.copy()
print(df1)