Convert Series to pandas DataFrame in Python (2 Examples) | Create Column | to_frame() & DataFrame()

preview_player
Показать описание
Python code of this video:

import pandas as pd # Load pandas

my_ser = pd.Series([1, 3, 5, 7, 9]) # Create example Series
print(my_ser) # Print example Series
# 0 1
# 1 3
# 2 5
# 3 7
# 4 9
# dtype: int64

print(my_data1) # Print pandas DataFrame

my_data2 = pd.DataFrame({'x': my_ser}) # Convert Series to DataFrame
print(my_data2) # Print pandas DataFrame

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

not many people explain these concepts so intently! thank you so much u are a life saver for all the struggling students!

lilly-mhvf