Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Machine Learning by (19k points)

Hi. I have written a python pandas script

old_df = pd.read_csv('User data.csv')

up_df = {'Name': names, 'New Points': point_list}

for name in up_df['Name']:

    for old_name in old_df['Name']:

        if name==old_name:




  [i[0],'New Points']=up_df[j[0],'New Points']

But I am getting this error at the bold line in the script above

KeyError: False

Please help

1 Answer

0 votes
by (33.1k points)

The reason for this error is that you have created a dictionary

up_df = {'Name': names, 'New Points': point_list}

but you are treating it as a pandas dataframe


You have to create a pandas dataframe first. 

For example:

up_df1 = {'Name': names, 'New Points': point_list}


For more details on Python Pandas, study the Python Course. Also, study the Machine Learning Certification Course by Intellipaat for more details on this. Hope this answer helps you!

Browse Categories