Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

06.1 Question matching -- KeyError: "None of ['Id'] are in the columns" #69

Open
mikechen66 opened this issue May 3, 2020 · 0 comments

Comments

@mikechen66
Copy link

Dear Douwe

There is a None of ['Id'] issue. Please help solve the issue.

df = pd.DataFrame.from_records(rows)
df = df.set_index('Id', drop=False)
df['Title'] = df['Title'].fillna('').astype('str')
df['Tags'] = df['Tags'].fillna('').astype('str')
df['Body'] = df['Body'].fillna('').astype('str')
df['Id'] = df['Id'].astype('int')
df['PostTypeId'] = df['PostTypeId'].astype('int')
df['ViewCount'] = df['ViewCount'].astype('float')

df.head()


KeyError Traceback (most recent call last)
in
1 df = pd.DataFrame.from_records(rows)
----> 2 df = df.set_index('Id', drop=False)
3 df['Title'] = df['Title'].fillna('').astype('str')
4 df['Tags'] = df['Tags'].fillna('').astype('str')
5 df['Body'] = df['Body'].fillna('').astype('str')

/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in set_index(self, keys, drop, append, inplace, verify_integrity)
4301
4302 if missing:
-> 4303 raise KeyError(f"None of {missing} are in the columns")
4304
4305 if inplace:

KeyError: "None of ['Id'] are in the columns"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant