ID Number
1123 222222222222222
332 3333333333
112 222222222
This is my csv , how to remove by index
? or specific line ?
for i, produto in produtos.iterrows():
del produto[2]
i try this one tu delete by index 2 "332"
Everything is correct except that instead of producto[2]
use producto[i]
The full code is:
for i, produto in produtos.iterrows():
del produto[i]
df = pd.DataFrame( {'ID': [1123, 332, 112], 'Number': [222222222222222, 3333333333, 222222222]} )
df = df.drop(index=1)
print(df)
Prints:
ID Number
0 1123 222222222222222
2 112 222222222
If ID is index, then:
df = pd.DataFrame({'ID': [1123, 332, 112], 'Number': [222222222222222, 3333333333, 222222222]}).set_index('ID')
df = df.drop(index=332)
print(df)
Prints:
Number
ID
1123 222222222222222
112 222222222
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.