I am trying to drop a single row in a csv-file using pandas lib for python. The row that should be dropped contains a specific id. While executing the script, I always get a KeyError: "['12345'] not found in axis". Does anybody have a solution?
Example dataframe:
id date time
12345 11-7 11am
12346 11-7 12pm
12347 11-7 1pm
The code:
import pandas as pd
id = "123456"
filename = datacollection.csv
data = pd.read_csv(filename, encoding="utf-8", index_col="id")
data.drop(id, axis=0, inplace=True)
Expected result would be:
id date time
12346 11-7 12pm
12347 11-7 1pm
Easy as that. However, I tried a lot of different solutions provided on various sites on the internet but nothing worked.