Learner
Learner

Reputation: 691

Add string url inside pandas dataframe

I have a url as string :- url='https://www.business-standard.com/article/technology/xiaomi-mi-a2-india-launch-today-how-to-watch-livestream-know-specs-price-118080800144_1.html'.

I want to add this url into pandas dataframe as text'. All I did as:-

data=pd.DataFrame(url,columns=['url'])

It gives error as:

ValueError:DataFrame constructor not properly called!

I don't get it where I did wrong?

Expected output :

url
https://www.business-standard.com/article/technology/xiaomi-mi-a2-india-launch-today-how-to-watch-livestream-know-specs-price-118080800144_1.html
........................
........................
.......................

Upvotes: 3

Views: 602

Answers (1)

jezrael
jezrael

Reputation: 863256

Convert string to one element list by []:

data=pd.DataFrame([url],columns=['url'])
print (data)
                                                 url
0  https://www.business-standard.com/article/tech...

Upvotes: 2

Related Questions