-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Strange behavior when combining astype and loc #13260
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 as expected; use getitem if you want to re-assign w/o masking. In this case your mask is ':' (meaning the entire columns), but upcasting is done when used in this way (and that's why its upcast to IOW,
|
This is a bit related to the docs we added here: #13070 If you'd like to propose an example for this section would take it: http://pandas-docs.github.io/pandas-docs-travis/basics.html#astype (e.g. showing pitfalls, e.g. this example) |
Subtle point, indeed. Thanks for the clarification. |
let me reopen as a doc-issue. |
I am trying to use
astype
together withloc
to convert just a subset of columns to a specified dtype. However, I can't understand what is actually happening. Is this the expected behavior when combiningastype
andloc
?Code Sample, a copy-pastable example if possible
Output:
Expected Output
output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.2.0-36-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.0
nose: None
pip: 8.1.1
setuptools: 20.6.7
Cython: None
numpy: 1.11.0
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
The text was updated successfully, but these errors were encountered: