how to build a dataframe code example
Example 1: how to create dataframe in python
import pandas as pd
data = {'Name':['Tom', 'nick', 'krish', 'jack'],
'Age':[20, 21, 19, 18]}
df = pd.DataFrame(data)
df
Example 2: how do we create a dataframe in python
import pandas as pd
data = [['Group A', 85], ['Group B', 92], ['Group C', 88]]
df = pd.DataFrame(data, columns = ['Name', 'Score'])
df
Example 3: creating a pandas df
>>> d = {'col1': [1, 2], 'col2': [3, 4]}
>>> df = pd.DataFrame(data=d)
>>> df
col1 col2
0 1 3
1 2 4