diff --git a/pandas/core/panel.py b/pandas/core/panel.py index 1e6ed56386f63..5aa6aef150035 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -8,6 +8,7 @@ from pandas import compat import sys import numpy as np +import warnings from pandas.core.common import (PandasError, _try_sort, _default_index, _infer_dtype_from_scalar, notnull) from pandas.core.categorical import Categorical @@ -858,6 +859,11 @@ def to_frame(self, filter_observations=True): mask = com.notnull(self.values).all(axis=0) # size = mask.sum() selector = mask.ravel() + if not selector.all(): + warnings.warn("Panel to_frame method discards entries with " + "NaN/None in the data by default, use " + "filter_observations = False to save them", + UserWarning) else: # size = N * K selector = slice(None, None) diff --git a/pandas/tests/test_panel.py b/pandas/tests/test_panel.py index fb1f1c1693fdd..405545117deb4 100644 --- a/pandas/tests/test_panel.py +++ b/pandas/tests/test_panel.py @@ -1496,7 +1496,11 @@ def test_to_frame_multi_major(self): assert_frame_equal(result, expected) wp.iloc[0, 0].iloc[0] = np.nan # BUG on setting. GH #5773 - result = wp.to_frame() + + with tm.assert_produces_warning(UserWarning): + setattr(panelm, '__warningregistry__', {}) + result = wp.to_frame() + assert_frame_equal(result, expected[1:]) idx = MultiIndex.from_tuples([(1, 'two'), (1, 'one'), (2, 'one'),