Slice pandas DataFrame by Index in Python (Example) | Split at Particular Row | How to Divide Data

preview_player
Показать описание
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

print(data_upper) # Print DataFrame of upper rows

print(data_lower) # Print DataFrame of lower rows

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

Thanks for the video. This helped me solve a problem with my script.

MrPelastus
Автор

Please, How to split data of one column into multiple equal n columns in Excel? ( I have along Column with 10000 values. I want to split it in n columns with 53 values each).

fateherbentah
Автор

hey hi, i have an python script for querying a database and get output. now in my output using dataframe 4 rows 6 columns. for 1st coloumn of data belongs 1 person of 2 rows and other rows of data belongs to other person. now if want to send a 1st person data which is first 2 rows and 2nd person of data the other rows. how can i divide and send and how to put condition to match for if 1st rows of 1st columns having X name and other rows of the same column Y name. please help

pavankumarsapta