Issue
I imported CSV files with over 500k rows, one year, every minute. To merge two of this files, i want so re-sample the index to every minute:
Temp= pd.read_csv("Temp.csv", sep=";", decimal="," , thousands='.' ,encoding="cp1252")
Temp["Time"] = pd.to_datetime(Temp["Time"],dayfirst=True)
Temp.set_index(['Time'], inplace=True)
Temp= Temp.resample('1Min').ffill()
But I got the error:
cannot reindex a non-unique index with a method or limit
How can i find the "non-unique" rows?
Solution
My solution:
Temp= pd.read_csv("Temp.csv", sep=";", decimal="," , thousands='.' ,encoding="cp1252")
Temp.drop_duplicates(inplace=True)
Temp["Time"] = pd.to_datetime(Temp["Time"],dayfirst=True)
Temp.set_index(['Time'], inplace=True)
Temp= Temp.resample('1Min').ffill()
I used:
len(Temp.index)
and
len(set(Temp.index))
to find out, that there are Dublicates
Answered By - kolja
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.