Home > Software engineering >  Remove line in csv python Panda
Remove line in csv python Panda

Time:11-07

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"

CodePudding user response:

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]

CodePudding user response:

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
  • Related