How to return the first and last N columns from a pandas DataFrame in the Python programming language. More details: https://statisticsglobe.com/extract-f...
Python code of this video:
import pandas as pd # Load pandas library
data = pd.DataFrame({'x1':range(10, 15), # Create pandas DataFrame
'x2':range(0, 5),
'x3':['a', 'b', 'c', 'd', 'e'],
'x4':range(8, 3, - 1),
'x5':['x', 'y', 'x', 'y', 'x']})
print(data) # Print pandas DataFrame
data_first_n = data.iloc[:, :3] # Select first columns
print(data_first_n) # Print first columns
data_last_n = data.iloc[:, 3:] # Select last columns
print(data_last_n) # Print last columns
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – Group for Discussions & Questions: / statisticsglobe
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – Group for Discussions & Questions: / 12555223
Twitter: / joachimschork
Music by bensound.com
Auf dieser Seite können Sie das Online-Video How to Extract First & Last N Columns from pandas DataFrame in Python (2 Examples) | iloc Attribute mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Statistics Globe 11 Mai 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 880 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!