-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
object of type 'CategoricalDtype' has no len() #22262
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
Can you make a reproducible example? http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports |
@TomAugspurger thanks for the interest, snippet can now be run as is and will trigger the same error. |
Can you paste the full traceback running your snippet? The line new = pd.DataFrame(dtype= { "tcpdest": dtype_role }) is invalid, since
|
arf indeed, I am used to using read_csv which accept a |
I think there's an enhancement request for that. |
Code Sample, a copy-pastable example if possible
Using 0.23.3
My goal: I have an enum with 2 values Client/Server and would like to make use of the categorical dtype for performance reasons.
triggers
Problem description
[this should explain why the current behaviour is a problem and why the expected output is a better solution.]
I want to specify the dtype otherwise pandas convert my enums into their integer values. I prefer to keep enums since when printing the dataframe it's easier to read "server" than "2".
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.14.24
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8
pandas: 0.23.3
pytest: None
pip: 18.0
setuptools: 40.0.0
Cython: 0.28.3
numpy: 1.14.5
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.6
feather: None
matplotlib: 2.2.2
openpyxl: 2.5.4
xlrd: 0.9.4
xlwt: 1.3.0
xlsxwriter: None
lxml: 4.2.3
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.10
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: