1import pandas as pd
2
3# intialise data of lists.
4data = {'Name':['Tom', 'nick', 'krish', 'jack'],
5 'Age':[20, 21, 19, 18]}
6
7# Create DataFrame
8df = pd.DataFrame(data)
9
10# Print the output.
11df
1import pandas as pd
2
3data = {'First Column Name': ['First value', 'Second value',...],
4 'Second Column Name': ['First value', 'Second value',...],
5 ....
6 }
7
8df = pd.DataFrame (data, columns = ['First Column Name','Second Column Name',...])
9print (df)
1>>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
2... columns=['a', 'b', 'c'])
3>>> df2
4 a b c
50 1 2 3
61 4 5 6
72 7 8 9
8
1# Import pandas library
2import pandas as pd
3
4# initialize list of lists
5data = [['Group A', 85], ['Group B', 92], ['Group C', 88]]
6
7# Create the pandas DataFrame
8df = pd.DataFrame(data, columns = ['Name', 'Score'])
9
10# print dataframe.
11df
1import numpy as np
2import pandas as pd
3vect1=np.zeros(10)
4vect2=np.ones(10)
5df=pd.DataFrame({'col1':vect1,'col2':vect2})
1import pandas as pd
2data = {
3 "A":[1,2,3],
4 "B":[4,5,6],
5 "C":[7,8,9]
6}
7index = [1,2,3,4,5,6,7,8,9]
8
9pd.DataFrame(data=data, index=index)
10