Write a program to create a Series object from an ndarray that stores characters from ‘a’ to ‘g’.

Опубликовано: 27 Октябрь 2024
на канале: Portal Express
523
10

Q. Write a program to create a Series object from an ndarray that stores characters from 'a' to 'g'.

Website Link :-
https://www.pathwalla.com/2020/11/wri...

Answer =


import pandas as pd
import numpy as np

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

Output :-

['a' 'b' 'c' 'd' 'e' 'f']
0 a
1 b
2 c
3 d
4 e
5 f
dtype: object