-2

I have an datframe like this:

product_name  image url
 product A
 product B   https://...
 product c  

here product A and B don't have any image url. How I can set an defult image url for product A and product c ?

0

1 Answer 1

1

using np.where, you can assign a default URL whereever the image URL is null

df['image_url'] = np.where(df['image_url'].isna(), 'http://default.url', df['image_url'])
df
    product_name    image_url
0   product A   http://default.url
1   product B   https://...
2   product c   http://default.url
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.