jeudi 6 mai 2021

Find Word in a csv file and implement it using loops

I am having a dataframe named df which is having two columns,

    Company name    Company website 
0   Maersk Drilling http://www.maerskdrilling.com/ 
1   CICLAGUA SA https://simetriagrupo.com/ 
2   Enel    http://www.enel.com/ 
3   Enovos Luxembourg   http://www.enovos.lu/ 
4   DTEK    http://www.dtek.com/

Now what i am trying to implement is I am trying to find out company name where "gc" word exists and store it into new dataframe df1.

for i in range(0,a):
    if 'gc' in df['Company name'][i]:
        df1["Company Name"]= df['Company name'][i]
        df1["URL"]=df['Company website'][i]
    else:
        pass
    

but this code is showing error

      1 for i in range(0,a):
----> 2     if 'word' in df['Company name'][i]:
      3         df1["Company Name"]= df['Company name'][i]
      4         df1["URL"]=df['Company website'][i]
      5     else:

TypeError: argument of type 'float' is not iterable

Aucun commentaire:

Enregistrer un commentaire