xxxxxxxxxx
import pandas as pd
data = {"Name": ['Phillip', 'Donald', 'Fankhola', 'Mixo', 'Delight', 'Vuyo'],
"Surname": ['Moyo', 'Phutiane', 'Siphotoma', 'Ngobeni', 'Chauke', 'Shabango'],
"Age": [25, 23, 24, 24, 23, 23]}
df = pd.DataFrame(data)
df
xxxxxxxxxx
import pandas as pd
# intialise data of lists.
data = {'Name':['Tom', 'nick', 'krish', 'jack'],
'Age':[20, 21, 19, 18]}
# Create DataFrame
df = pd.DataFrame(data)
# Print the output.
df
xxxxxxxxxx
import pandas as pd
data = {'First Column Name': ['First value', 'Second value', ],
'Second Column Name': ['First value', 'Second value', ],
.
}
df = pd.DataFrame (data, columns = ['First Column Name','Second Column Name', ])
print (df)
xxxxxxxxxx
import numpy as np
import pandas as pd
vect1=np.zeros(10)
vect2=np.ones(10)
df=pd.DataFrame({'col1':vect1,'col2':vect2})
xxxxxxxxxx
# Import pandas library
import pandas as pd
# initialize list of lists
data = [['Group A', 85], ['Group B', 92], ['Group C', 88]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['Name', 'Score'])
# print dataframe.
df
xxxxxxxxxx
>>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
columns=['a', 'b', 'c'])
>>> df2
a b c
0 1 2 3
1 4 5 6
2 7 8 9
xxxxxxxxxx
import pandas as pd
import numpy as np
df = pd.DataFrame(np.array([[1, 2, 3, 5], [4, 5, 6, 7], [7, 8, 9, 1]]),
columns=['a', 'b', 'c', 'd'])
xxxxxxxxxx
import pandas as pd
data = {
"A":[1,2,3],
"B":[4,5,6],
"C":[7,8,9]
}
index = [1,2,3,4,5,6,7,8,9]
pd.DataFrame(data=data, index=index)
xxxxxxxxxx
# Import pandas library
import pandas as pd
# initialize list of lists
data = [['tom', 10], ['nick', 15], ['juli', 14]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns=['Name', 'Age'])
# print dataframe.
df