File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -847,16 +847,30 @@ def empty(self):
847
847
848
848
Notes
849
849
-----
850
- If NDFrame contains only NaNs, it is still not considered empty.
850
+ If NDFrame contains only NaNs, it is still not considered empty. See
851
+ the example below.
851
852
852
853
Examples
853
854
--------
855
+ An example of an actual empty DataFrame. Notice the index is empty:
856
+
857
+ >>> df_empty = pd.DataFrame({'A' : []})
858
+ >>> df_empty
859
+ Empty DataFrame
860
+ Columns: [A]
861
+ Index: []
862
+ >>> df_empty.empty
863
+ True
864
+
865
+ If we only have NaNs in our DataFrame, it is not considered empty! We
866
+ will need to drop the NaNs to make the DataFrame empty:
854
867
855
- >>> # containing only NaNs does not make the df empty
856
868
>>> df = pd.DataFrame({'A' : [np.nan]})
869
+ >>> df
870
+ A
871
+ 0 NaN
857
872
>>> df.empty
858
873
False
859
- >>> # if we drop NAs, the axes are now of length 0
860
874
>>> df.dropna().empty
861
875
True
862
876
You can’t perform that action at this time.
0 commit comments