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

Time:10-22

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

CodePudding user response:

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

df.reset_index()

CodePudding user response:

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

  • Related