get_first_element_of_series_if_not_empty
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
get_first_element_of_series_if_not_empty [2021/01/16 07:41] – [get first element of series if not empty] raju | get_first_element_of_series_if_not_empty [2021/01/17 02:04] (current) – [Solution] raju | ||
---|---|---|---|
Line 12: | Line 12: | ||
df.loc[mask][' | df.loc[mask][' | ||
</ | </ | ||
- | since iloc[0] will throw the exception | + | since iloc[0] will throw |
< | < | ||
IndexError: single positional indexer is out-of-bounds | IndexError: single positional indexer is out-of-bounds | ||
</ | </ | ||
- | if df.loc[mask] is empty. | + | exception |
For example | For example | ||
Line 58: | Line 58: | ||
next(iter(df.loc[mask][' | next(iter(df.loc[mask][' | ||
</ | </ | ||
+ | or next(iter(series), | ||
+ | |||
With the above example | With the above example | ||
< | < |
get_first_element_of_series_if_not_empty.1610782893.txt.gz · Last modified: 2021/01/16 07:41 by raju