Write a Pandas program to convert Series of lists to one Series
- برمجة بي اتش بي
- 2021-09-10
- mhanasmh00489829403
الأجوبة
import pandas as pd
s = pd.Series([
['Red', 'Green', 'White'],
['Red', 'Black'],
['Yellow']])
print("Original Series of list")
print(s)
s = s.apply(pd.Series).stack().reset_index(drop=True)
print("One Series")
print(s)
Sample Output:
Original Series of list 0 [Red, Green, White] 1 [Red, Black] 2 [Yellow] dtype: object One Series 0 Red 1 Green 2 White 3 Red 4 Black 5 Yellow dtype: object
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال