4 ms·
For me, len() is much less ambiguous. Also in Pandas if you try to check the truth value of a dataframe to see if it’s empty, it will fail. It will say “the tr
by wenc 2y ago
For me, len() is much less ambiguous.
Also in Pandas if you try to check the truth value of a dataframe to see if it’s empty, it will fail. It will say “the truth value of a dataframe is ambiguous”.
df.empty is less ambiguous but you have to remember it specifically for dataframes.
But len(df) > 0 almost always works for any type of collection.