Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Series.empty#

propertySeries.empty[source]#

Indicator whether Series/DataFrame is empty.

True if Series/DataFrame is entirely empty (no items), meaning any of theaxes are of length 0.

Returns:
bool

If Series/DataFrame is empty, return True, if not return False.

See also

Series.dropna

Return series without null values.

DataFrame.dropna

Return DataFrame with labels on given axis omitted where (all or any) data are missing.

Notes

If Series/DataFrame contains only NaNs, it is still not considered empty. Seethe example below.

Examples

An example of an actual empty DataFrame. Notice the index is empty:

>>>df_empty=pd.DataFrame({'A':[]})>>>df_emptyEmpty DataFrameColumns: [A]Index: []>>>df_empty.emptyTrue

If we only have NaNs in our DataFrame, it is not considered empty! Wewill need to drop the NaNs to make the DataFrame empty:

>>>df=pd.DataFrame({'A':[np.nan]})>>>df    A0 NaN>>>df.emptyFalse>>>df.dropna().emptyTrue
>>>ser_empty=pd.Series({'A':[]})>>>ser_emptyA    []dtype: object>>>ser_empty.emptyFalse>>>ser_empty=pd.Series()>>>ser_empty.emptyTrue

[8]ページ先頭

©2009-2025 Movatter.jp