How to convert a pandas dataframe with non unique indexes into a one with unique indexes?

Question:

I created a dataframe with some previous operations but when I query a column name with an index (for example, df[‘order_number][0] ), multiple rows/records come as output.
The screenshot shows the unique and total indexes of the dataframe. image shows the difference in lengths of uniques indexes and all indexes

Asked By: sa7tama

||

Answers:

Could you should a df.head() for example, usually when you consume a data source, if you sent the arg indexto True each row will be assigned a unique numerical index

Answered By: Nyasha Chizampeni

It looks like the data kept their index when you merged/joined df. Try:

df.reset_index()
Answered By: Hanna
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.