Skip to content

Commit 032fba7

Browse files
committed
Address review comments
1 parent 167d371 commit 032fba7

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎CHANGES.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,11 @@ astropy.stats
12521252
astropy.table
12531253
^^^^^^^^^^^^^
12541254

1255-
- Fixed a bug where ``int64`` get converted to float and lose precision when
1256-
converted back via ``to_pandas()``. This fix only applies to masked column
1257-
that is not really masked. [#7741, #7747]
1255+
- Fixed a bug in ``to_pandas()`` where integer type masked columns were always
1256+
getting converted to float. This could cause loss of precision. Now this only
1257+
occurs if there are actually masked data values, in which case ``pandas``
1258+
does require the values to be float so that ``NaN`` can be used to mark the
1259+
masked values. [#7741, #7747]
12581260

12591261
astropy.tests
12601262
^^^^^^^^^^^^^

‎astropy/table/table.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,6 +2724,9 @@ def to_pandas(self):
27242724
if isinstance(column, MaskedColumn) and np.any(column.mask):
27252725
if column.dtype.kind in ['i', 'u']:
27262726
out[name] = column.astype(float).filled(np.nan)
2727+
warnings.warn(
2728+
"converted column '{}' from integer to float".format(
2729+
name), TableReplaceWarning, stacklevel=3)
27272730
elif column.dtype.kind in ['f', 'c']:
27282731
out[name] = column.filled(np.nan)
27292732
else:

0 commit comments

Comments
 (0)