Get List of Column Names Grouped by Data Type in Python (Example) | to_series() & groupby() Function

Veröffentlicht am: 23 Dezember 2022
auf dem Kanal: Statistics Globe
97
4

How to return a list of column names grouped by the type of the column in the Python programming language. More details: https://statisticsglobe.com/get-list-...
Python code of this video:

import pandas as pd # Import pandas library in Python

data = pd.DataFrame({'x1':['a', 'b', 'c', 'd', 'e'], # Create example DataFrame
'x2':range(6, 1, - 1),
'x3':[2, 5, 5, 8, 3],
'x4':['x', 'x', 'x', 'x', 'x'],
'x5':range(1, 6)})
print(data) # Print example DataFrame

print(data.columns.to_series().groupby(data.dtypes).groups)
{int64: ['x2', 'x3', 'x5'], object: ['x1', 'x4']}

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


Auf dieser Seite können Sie das Online-Video Get List of Column Names Grouped by Data Type in Python (Example) | to_series() & groupby() Function mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Statistics Globe 23 Dezember 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 97 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!