Skip to content

Unexpected output using brackets vs. parents in dataframe.loc #12411

Closed
@AbeHandler

Description

@AbeHandler

I have a dataframe, a_dataframe. I want to access the value at index=a, column=0. I can do this successfully with a_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

`self.assertEqual(a_dataframe.loc["a", "0"], a_dataframe.loc("a", "0"))` 

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions