python i have error in nonetype how to slove it

python i have error in nonetype how to slove it

Here i am trying to get domain names of the companies and the company names are stored in new.csv  

**The code i have used**  

    import pandas as pd
    import clearbit
    import json
    clearbit.key = 'sk_1915de5d2d7b6e245d6613e3d2188368'
    df = pd.read_csv("/home/vipul/Desktop/new.csv", sep=',', encoding="utf-8")
    saved_column = df['Company'].dropna()
    print(saved_column)
    i=0
    res = []
    for data in saved_column:   
        n = saved_column[i]
        i = i+1
        data = clearbit.NameToDomain.find(name=n)
        if data is None null() res.append(data['domain'])
        print(res)
    df['domain'] = res
    df.to_csv("/home/vipul/Desktop/new.csv",index = False, skipinitialspace=False)
    
    print("File saved to desktop as new.csv")

Open in new window

**output of the code**
    python ts.py
    0                ‎Accenture
    1              ‎AND Digital
    2                ‎Accenture
    3    ‎Kite Consulting Group
    4                ‎Capgemini
    5             ‎Accenture UK
    Name: Company, dtype: object
    ['accenture.com']
    ['accenture.com', 'and.digital']
    ['accenture.com', 'and.digital', 'accenture.com']
    Traceback (most recent call last):
      File "ts.py", line 15, in <module>
        res.append(data['domain'])
    TypeError: 'NoneType' object is not subscriptable

Open in new window



 

How to give some default value where NoneType encounters and store it with the corresponding company names which is in new.csv

**Expected output to be saved in new.csv**

    Company                  domain
    ‎Accenture                accenture.com
    ‎AND Digital              and.digital
    ‎Accenture                accenture.com
    ‎Kite Consulting Group    None
    ‎Capgemini                capgemini.com
    ‎Accenture UK             None
Vipul RaoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
pandas

From novice to tech pro — start learning today.