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
Watch video Get List of Column Names Grouped by Data Type in Python (Example) | to_series() & groupby() Function online, duration hours minute second in high quality that is uploaded to the channel Statistics Globe 23 December 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 97 times and liked it 4 visitors.