Hello, I'm a beginner studying Python DataFrame.
I was dealing with DataFrame, and I didn't know anything about it, so I tried googling, but I couldn't find it, so I'm asking you a question.
I want to read the first df in Excel and make a new DataFrame that meets certain conditions in the value, but it didn't work well, so I'm asking you a question. For example, if I print only the area I want, it comes out as below. If you look at the row number below, it's 14, 15, 16, but I'm going to go back to 0, 1, 2, 3, 4... I want to make it a new DataFrame that starts with . I think it's simple, but I don't know the keyword and it doesn't come out well even if I search this and that.ㅠ<
// If you put the conditions you want in df, it comes out like this.
df_2=df_1.iloc[cnt1:cnt1+cnt2, :]
print(df_2)
a1 Unnamed: 1 Unnamed:2 idx3
14 a2 0 0 ex2.x.8
15 p p1 p2 ex2.x.9
16 q q1 q2 ex1.x.5
// I want DataFrame to come out like this.
a1 Unnamed: 1 Unnamed:2 idx3
1 a2 0 0 ex2.x.8
2 p p1 p2 ex2.x.9
3 q q1 q2 ex1.x.5
Write df.reset_index(drop=True, inplace=True)
© 2024 OneMinuteCode. All rights reserved.