Write a Pandas program to convert a Panda module Series to Python list and it’s type

  • برمجة بايثون

Write a Pandas program to convert a Panda module Series to Python list and it’s type.

الأجوبة

import pandas as pd
ds = pd.Series([2, 4, 6, 8, 10])
print("Pandas Series and type")
print(ds)
print(type(ds))
print("Convert Pandas Series to Python list")
print(ds.tolist())
print(type(ds.tolist()):
Sample Output:
Pandas Series and type                                                 
0     2                                                                
1     4                                                                
2     6                                                                
3     8                                                                
4    10                                                                
dtype: int64                                                           
<class 'pandas.core.series.Series'>                                    
Convert Pandas Series to Python list                                   
[2, 4, 6, 8, 10]                                                       
<class 'list'>
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...