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
Watch video Slice pandas DataFrame by Index in Python (Example) | Split at Particular Row | How to Divide Data online, duration hours minute second in high quality that is uploaded to the channel Statistics Globe 06 July 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 2,410 times and liked it 20 visitors.