Using series ‘empty’ attribute, we can check whether the series is empty or not. ‘empty’ attribute return a boolean True, when the series is empty, else False.
Example
primes_series.empty
Find the below working application.
series_empty_check.py
import pandas as pd
# Series holds element of type int64
primes_list = [2, 3, 5, 7, 11]
primes_series = pd.Series(primes_list)
empty_series = pd.Series([])
print('Is primes_series empty ? ', primes_series.empty)
print('Is empty_series empty ? ', empty_series.empty)
Output
Is primes_series empty ? False Is empty_series empty ? True
No comments:
Post a Comment