Articles → Pandas → Series In Pandas
Series In Pandas
What Is A Series In Pandas?
Example
import pandas as pd
my_list = [10,20,30]
print(pd.Series(my_list))
Click to Enlarge
Customizing The Labels In Series
import pandas as pd
my_list = [10,20,30]
labels = ['I', 'II', 'III']
print(pd.Series(my_list, labels))
Click to Enlarge
- Dtype means the type of data a series holds.
- Number of elements in label array should be same as list.
Converting Numpy Array To Series
import numpy as np
import pandas as pd
my_list = [10,20,30]
arr = np.array(my_list)
print(pd.Series(arr))
Click to Enlarge
Converting Dictionary Into Series
import pandas as pd
d = {'a':10,'b':20,'c':30}
print(pd.Series(d))
Click to Enlarge
Print Series
import numpy as np
import pandas as pd
d = {'a':10,'b':20,'c':30}
ser = pd.Series(d)
# Printing the series
print(ser['a'])
Using Labels As Data