标题中的警告是由Python 3.6.3上的pandas 0.21.0生成的,其代码如下pd.Series(["a", "b", "b"]).astype("category", categories = ["a", "b", "c"]).现在应该怎么写这个呢?
Kod*_*ist 13
将CategoricalDtype在警告中提到可作为pd.api.types.CategoricalDtype.所以,你可以写pd.Series(["a", "b", "b"]).astype(pd.api.types.CategoricalDtype(categories = ["a", "b", "c"])).