You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, you may pass a numpy.MaskedArray as the data argument to the DataFrame constructor, and its masked entries will be considered missing.
The above works if dtype is omitted; all values are "upgraded" to floats.
Expected Output
Several possibilities:
This is expected behavior. If so, it would be nice to have the documentation linked above note that masked structured NumPy arrays are not supported. The code should also raise the appropriate exception informing the user these arrays are not supported (e.g. ValueError?).
This functionality is supported. If so, this appears to be a bug.
Functionality is supported, but with extra steps. It seems as though this conversion is possible with these steps.
Use numpy.ma.MaskedArray.filled and fill the NumPy masked array with "special" (e.g. 1e20, 99999) values based on data type.
Convert the array to a DataFrame.
Convert any integer series to the nullable int type Int64.
Replace the same filled values to appropriate NULL values, e.g. NaN, pd.NA.
Options to address the latter case can be either supported in code or else documentation.
This issue was discussed on StackOverflow here (my question).
Output of pd.show_versions()
INSTALLED VERSIONS
commit : f00ed8f
python : 3.8.8.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
OK, good to know. Shame though since there is a clear path between the two, although the same could be said from a DataFrame with "null" values to a structured masked NumPy array. Then perhaps a small note in the reference documentation to say this would be great.
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
This is somewhere between a bug report and a feature request? The above code returns this error:
The documentation notes that:
The above works if
dtype
is omitted; all values are "upgraded" to floats.Expected Output
Several possibilities:
ValueError
?).DataFrame
.Int64
.NaN
,pd.NA
.Options to address the latter case can be either supported in code or else documentation.
This issue was discussed on StackOverflow here (my question).
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f00ed8f
python : 3.8.8.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.0
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.1.3
setuptools : 52.0.0.post20210125
Cython : 0.29.24
pytest : 6.2.4
hypothesis : None
sphinx : 4.0.2
blosc : None
feather : None
xlsxwriter : 1.4.4
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 3.0.1
IPython : 7.22.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 2021.07.0
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.21
tables : 3.6.1
tabulate : None
xarray : 0.18.2
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.0
The text was updated successfully, but these errors were encountered: