Skip to content

unexpected numpy array returned when using .loc #27695

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

Closed
sunt05 opened this issue Aug 1, 2019 · 1 comment
Closed

unexpected numpy array returned when using .loc #27695

sunt05 opened this issue Aug 1, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@sunt05
Copy link

sunt05 commented Aug 1, 2019

Code Sample, a copy-pastable example if possible

# Your code here
dt=pd.date_range('2012','2013',freq='d')
df_test=pd.DataFrame(index=dt)
df_test['x']=123
df_test.loc['2012 2','x']

Problem description

.loc operation above used to return a pd.Series but in v0.25.0 returns a numpy array.

Expected Output

output:

array([123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
       123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
       123, 123, 123])

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.3.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.25.0
numpy : 1.17.0
pytz : 2019.1
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : 0.29.12
pytest : 5.0.1
hypothesis : None
sphinx : 2.1.2
blosc : None
feather : None
xlsxwriter : 1.1.8
lxml.etree : 4.3.4
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.7.6.1 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : 7.6.1
pandas_datareader: None
bs4 : 4.7.1
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.3.4
matplotlib : 3.1.0
numexpr : 2.6.9
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.0
sqlalchemy : 1.3.5
tables : 3.5.2
xarray : 0.12.1
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.8

@TomAugspurger
Copy link
Contributor

Duplicate of #27516 (I just changed the title to be more accurate).

Going to fix for 0.25.1. In the meantime you can do two indexing calls, df_test.loc['2012-02']['x'].

@TomAugspurger TomAugspurger added the Duplicate Report Duplicate issue or pull request label Aug 1, 2019
@TomAugspurger TomAugspurger added this to the No action milestone Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants