World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
How to save a CSV file from the 21st row to the 45th row If I have a data frame of 100 rows
Here is an example of how you can save a csv file from row 21 to 45 of a data frame in Python: import pandas as pd
# Load your data frame
df = pd.read_csv('your_data_frame.csv')
# Select rows 21 to 45
df = df[20:45]
# Save the new data frame as a csv file
df.to_csv('subset_of_your_data_frame.csv', index=False) .
Note that the index starts from 0, so the 21st row is indexed as 20 and the 45th row is indexed as 44