Search code examples
pandasdataframeweb-scraping

How to remove "₦" currency from column using Dataframe


i scrape a website and after using "pandas.dataframe()" to view the data, i get the table below but i want to remove the "₦" sign from the pric column. it is difficult for me because computer doesn"t recognize the currency. i cannot use replace().this is my code;

URL= "https://www.weyn.com.ng/computing/"

web= requests.get(URL) 

soup= BeautifulSoup(web.content, "html.parser")

result= soup.find_all("article", {"class":"prd _fb col c-prd"})


computer= [computer_type.find("h3",{"class":"name"}).get_text() for computer_type in result]

price= [computer_price.find("div",{"class":"prc"}).get_text() for computer_price in result]


table= ({"comput": computer,
     "pric":price})
tab= pd.DataFrame(table)

print(tab)

OUTPUT

                                         comput       pric
0   Hp 15 Intel Pentium (500GB HDD, 8GB RAM) Windo...   ₦ 130290
1   Hp 15 Intel Pentium Dual Core 2.3ghz (4GB,500 ...   ₦ 122690
2   Hp 15 AMD Dual Core 500GB HDD 4GB RAM 15.6" WI...    ₦ 93290
3   Hp Notebook 15 Intel Core I3 (8GB RAM, 1TB HDD...   ₦ 156000

Solution

  • You can try this

    tab= pd.DataFrame(table)

    tab['pric'] = tab['pric'].replace({'₦':' '}, regex=True)