-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
DataFrame with PeriodIndex causes KeyError on get_value #15268
Comments
Futher what you are doing is quite non-performant, iterating over the rows is not recommended.
|
It is I agree that you don't need to use this method in the current example, but still, it is a public, documented method that in this case totally fails to do what is documented it should. According to the docstring it takes row and column labels, which fails:
Shouldn't we just fix this? Or update the documentation to discourage its usage? (or both) |
Probably not the place but, could you please explain a better way to populate each of he columns based on conditional analysis of external time stamped data being counted for each of the periods in the PeriodIndex? |
@devanl you can better ask on StackOverflow (and be sure to give there a reproducible example with a clear expected result, as this is currently not fully clear to me) |
These are effectively internal method and should actually be deprecated. I thought we did this quite a while back. |
Code Sample, a copy-pastable example if possible
Problem description
If I comment out the setting of index this works as expected with PeriodIndex defined this creates KeyError.
Output of
pd.show_versions()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.1\helpers\pydev\pydevd.py", line 2403, in
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.1\helpers\pydev\pydevd.py", line 1794, in run
launch(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.1\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/dlippman/src/ETDataView/test.py", line 19, in
f_count = bins.get_value(idx, 'foo')
File "C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\pandas\core\frame.py", line 1900, in get_value
return engine.get_value(series.get_values(), index)
File "pandas\index.pyx", line 105, in pandas.index.IndexEngine.get_value (pandas\index.c:3567)
File "pandas\index.pyx", line 113, in pandas.index.IndexEngine.get_value (pandas\index.c:3250)
File "pandas\index.pyx", line 163, in pandas.index.IndexEngine.get_loc (pandas\index.c:4373)
KeyError: Period('2016-10-17', 'D')
The text was updated successfully, but these errors were encountered: