How to split a pandas DataFrame at a certain row index position in the Python programming language. More details: https://statisticsglobe.com/slice-pan...
Python code of this video:
import pandas as pd # Load pandas
data = pd.DataFrame({'x1':range(10, 18), # Create pandas DataFrame
'x2':['a', 'b', 'b', 'c', 'd', 'a', 'b', 'd'],
'x3':range(27, 19, - 1),
'x4':['x', 'z', 'y', 'y', 'x', 'y', 'z', 'x']})
print(data) # Print pandas DataFrame
split_point = 3 # Define split point
print(split_point) # Print split point
3
data_upper = data.iloc[:split_point] # Create upper data set
print(data_upper) # Print DataFrame of upper rows
data_lower = data.iloc[split_point:] # Create lower data set
print(data_lower) # Print DataFrame of lower rows
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
On this page of the site you can watch the video online Slice pandas DataFrame by Index in Python (Example) | Split at Particular Row | How to Divide Data with a duration of hours minute second in good quality, which was uploaded by the user Statistics Globe 06 July 2022, share the link with friends and acquaintances, this video has already been watched 2,410 times on youtube and it was liked by 20 viewers. Enjoy your viewing!