Home > Blockchain >  ValueError: cannot handle a non-unique multi-index! even when we have unique index
ValueError: cannot handle a non-unique multi-index! even when we have unique index

Time:03-25

I asked a question last days and I got the accepted response for that. Here is the question,

enter image description here

Does anybody know how to solve this problem? Thank you so much.

CodePudding user response:

You have 254 rows where you have at least 2 data points for the same (point_id, date). What do you want to do with records for a same (point_id, date)? You can group this data and keep the mean, for instance.

Here is the list:

df = pd.read_csv('dft.csv', index_col=0)
counts = df.value_counts(['point_id', 'date'], sort=False).loc[lambda x: x > 1]
  • Related