1

I have an dataframe like this:

product_nmae
Productashd
productddsf
productkid

my expected dataframe will be look like this:

  product_nmae    unique_id
    Productashd    sku-1
    productddsf    sku-2
    productkid    sku-3

I tried this df['unique_id'] = df.index + 1 which giving result something like this

  product_nmae    unique_id
    Productashd       0
    productddsf       1
    productkid        3

how to get my expected result?

1 Answer 1

4

Create default index and for possible add sku convert to strings:

df = df.reset_index(drop=True)
df['unique_id'] = 'sku-' + (df.index + 1).astype(str)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.