Q. Write a program to create a Dataframe that stores two columns, which store the Series objects of the previous two questions (10 and 11).


Answer =

import pandas as pd
import numpy as np

arr = np.array(list('abcdef'))
print(arr)
s1 = pd.Series(arr)

tab = np.arange(5,55,5)
ser = pd.Series(tab)
print(ser)

dataf = pd.DataFrame({"col":ser,"col1":tab})
print(dataf)

Output :-

['a' 'b' 'c' 'd' 'e' 'f']
0     5
1    10
2    15
3    20
4    25
5    30
6    35
7    40
8    45
9    50
dtype: int32
   col  col1
0    5     5
1   10    10
2   15    15
3   20    20
4   25    25
5   30    30
6   35    35
7   40    40
8   45    45
9   50    50

>>>

3 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Where is the output??

    ReplyDelete
  2. Sir i think you have written tab instead of s1 in data frame

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post