这是一个已知的问题吗
CategoricalDtype
read_json中的dtype没有转换列dtype,或者代码中有错误吗?
import pandas as pd
df = pd.read_json(
"./data/data.json",
dtype={
#"facility": pd.CategoricalDtype, # does not work
"facility": 'category', # does work
"supplier": pd.CategoricalDtype, # does not work
}
)
df.info()
-----
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 facility 232 non-null category
3 supplier 111 non-null object
环境
MacOS 13.0.1 (22A400)
$ python --version
Python 3.9.13
$ pip list | grep pandas
pandas 1.5.2