Informatics Practices
Write a program to create a Dataframe that stores two columns, which store the Series objects of the previous two questions (12 and 13).
Answer
import pandas as pd
import numpy as np
data = np.array(['a', 'b', 'c', 'd', 'e', 'f', 'g'])
S1 = pd.Series(data)
arr = np.arange(1, 11)
S2 = pd.Series(arr * 5)
df = pd.DataFrame({'Characters': S1, 'Table of 5': S2})
print(df)Output
Characters Table of 5
0 a 5
1 b 10
2 c 15
3 d 20
4 e 25
5 f 30
6 g 35
7 NaN 40
8 NaN 45
9 NaN 50
Related Questions
Write a program to create a Series object from an ndarray that stores characters from 'a' to 'g'.
Write a program to create a Series object that stores the table of number 5.
Write a program to create a Dataframe storing salesmen details (name, zone, sales) of five salesmen.
Four dictionaries store the details of four employees-of-the-month as (empno, name). Write a program to create a dataframe from these.