-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Unexpected output using brackets vs. parents in dataframe.loc #12411
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
Comments
This is a standard Python and pandas way of indexing, there is much documentation : http://pandas.pydata.org/pandas-docs/stable/indexing.htm |
Is that something we can put an exception on? Or is that being used internally? |
no |
To back that up, here are some failures you get when you remove the
|
The |
Or, if |
It's not clear that the internals are using |
@MaximilianR The use-case you see in the tests that use call like |
yeh, this needs to stay like it is. We may need to pass more arguments e.g.
|
@jorisvandenbossche thanks |
@jreback yes, the kwargs are certainly needed, but the args as well? |
@jorisvandenbossche yes I suppose we could raise on non-zero len *args, might provide some kind of an error check. ok will reopen |
@AbeHandler want to do a pull-request? |
Could also just remove the |
@MaximilianR right I think in this case, since we are going out-of-the-way to be helpful, a nice error message pointing to the correct syntax would be useful. |
@jreback happy to do a pull request! |
closes pandas-dev#12411 closes pandas-dev#12045 closes pandas-dev#11594 closes pandas-dev#10571
I have a dataframe,
a_dataframe
. I want to access the value at index=a, column=0. I can do this successfully witha_dataframe.loc["a", "0"]
. However,a_dataframe.loc("a", "0")
returns an object! Note: parens, no brackets.I am new to Pandas, so this was very unexpected behavior in the API. I would think the API should throw an exception or issue a warning. This is a very, very subtle difference in syntax and I think it makes it very easy for new users to get confused.
Code Sample, a copy-pastable example if possible
Expected Output
true
output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.16.2
nose: 1.3.7
Cython: 0.23.2
numpy: 1.8.0rc1
scipy: 0.13.0b1
statsmodels: 0.6.1
IPython: 4.0.0
sphinx: 1.3.1
patsy: 0.4.1
dateutil: 2.2
pytz: 2013.7
bottleneck: None
tables: None
numexpr: 2.4.6
matplotlib: 1.3.1
openpyxl: 2.2.0-b1
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: 3.5.0
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.8
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
The text was updated successfully, but these errors were encountered: