We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
df=pd.DataFrame( [[75,1,'2013-07-15',], [44,3,'2014-04-02',], [15,2,'2013-05-23',], [93,1,'2014-04-04',]] ,columns=['Sales','Store','Date']) df.Date=pd.to_datetime(df.Date) gb=df.groupby('Store') gb.apply(lambda df: pd.Series([1,2,3]))
KeyError: "['Date'] not in index" If I comment out to_datetime(df.Date) to use string type for date, then it works fine.
to_datetime(df.Date)
INSTALLED VERSIONS python: 3.4.3.final.0 pandas: 0.17.0
KeyError Traceback (most recent call last) in () 8 df.Date=pd.to_datetime(df.Date) 9 gb=df.groupby('Store') ---> 10 gb.apply(lambda df: pd.Series([1,2,3]))
......I omit the intermediate traces for succinct.
/Users/apple/miniconda3/lib/python3.4/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter) 1119 mask = check == -1 1120 if mask.any(): -> 1121 raise KeyError('%s not in index' % objarr[mask]) 1122 1123 return _values_from_object(indexer)
KeyError: "['Date'] not in index"
The text was updated successfully, but these errors were encountered:
The bug is from here, as the original columns are not present in the result (quite reasonably): https://github.com/pydata/pandas/blob/8727182683543d9f953250a454b43dbcaf8ae4a8/pandas/core/groupby.py#L3120-L3129 I don't quite get the intention/need to coerce in this branch...
cc #10265 @bashtage
Sorry, something went wrong.
this is a dupe of #11324
fixed by this: #11460
No branches or pull requests
KeyError: "['Date'] not in index"
If I comment out
to_datetime(df.Date)
to use string type for date, then it works fine.more details follows:
INSTALLED VERSIONS
python: 3.4.3.final.0
pandas: 0.17.0
KeyError Traceback (most recent call last)
in ()
8 df.Date=pd.to_datetime(df.Date)
9 gb=df.groupby('Store')
---> 10 gb.apply(lambda df: pd.Series([1,2,3]))
......I omit the intermediate traces for succinct.
/Users/apple/miniconda3/lib/python3.4/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
1119 mask = check == -1
1120 if mask.any():
-> 1121 raise KeyError('%s not in index' % objarr[mask])
1122
1123 return _values_from_object(indexer)
KeyError: "['Date'] not in index"
The text was updated successfully, but these errors were encountered: