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
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
It looks like the data kept their index when you merged/joined df. Try:
df.reset_index()
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
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
It looks like the data kept their index when you merged/joined df. Try:
df.reset_index()