Convert pandas DataFrame to Series in Python (Example) | Create from Row | Apply squeeze() Function

Опубликовано: 09 Ноябрь 2022
на канале: Statistics Globe
723
15

How to create a pandas Series from a DataFrame in the Python programming language. More details: https://statisticsglobe.com/convert-p...
Python code of this video:

import pandas as pd # Load pandas library

data = pd.DataFrame({'x1':[10], # Create pandas DataFrame
'x2':[20],
'x3':[30],
'x4':[40],
'x5':[50]})
print(data) # Print pandas DataFrame

my_series = data.squeeze(axis = 0) # Apply squeeze
print(my_series) # Print pandas Series
x1 10
x2 20
x3 30
x4 40
x5 50
Name: 0, dtype: int64

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  

Music by bensound.com