Column loses category when using .loc for a one row dataframe #16360
Labels
Categorical
Categorical Data Type
good first issue
Indexing
Related to indexing on series/frames, not to indexes themselves
Needs Tests
Unit test(s) needed to prevent regressions
Milestone
If I convert a list of columns to type 'category'
Problem description
I am trying to convert my defined categorical columns to the category type. It works when the dataframe is longer than one row, but if it is only one row it keeps the datatype as object.
With only one row I get the following column outputs:
df.dtypes
Expected Output
I would expect the column to be type category even for one row.
df.dtypes
Output of
pd.show_versions()
pandas: 0.20.1
pytest: No
ne
pip: 9.0.1
setuptools: 35.0.2
Cython: None
numpy: 1.12.1
scipy: 0.18.1
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: None
xlsxwriter: 0.9.6
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: