-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
$ pip show pandas
Name: pandas
Version: 1.2.4
import pandas as pd
import numpy as np
lzt = ["a","b","c"]
arr = np.array(lzt)
df = pd.DataFrame(arr).astype('string')
srs = df[0]
u = srs.unique()
type(u)
<class 'pandas.core.arrays.string_.StringArray'>
u.dtype == 'string'
True
u.tolist()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'StringArray' object has no attribute 'tolist'
Problem description
So I tried changing my code to use list(srs.unique())
, but then all of my numeric dtypes become unserializable for JSON.
Output of pd.show_versions()
pandas : 1.2.4
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 2.0.0
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None