There is lists :
l_figure_s= [5, 9, 21, 25, 30, 34, 43]
l_figure_e= [8, 16, 24, 28, 33, 37, 46]
Of lists created dataframe :
df1 = pd.DataFrame.from_dict({'starts':l_figure_s,'ends':l_figure_e},dtype=int,orient='index').transpose()
You need to check elements by condition:
df1[ df1['starts']<df1['ends'] & df1['starts'].shift(-1)>=df['ends'] ]
The error occurs on the last line, I think the interpreter sees this condition : Nan >= 46
How to exclude condition check beyond the last line ?
Maybe you need a calculator for df['ends'] ?
CodePudding user response:
You have to use parenthesis:
df1[(df1['starts']<df1['ends']) & (df1['starts'].shift(-1)>=df1['ends'])]
EDIT: As @mozway says in the comments section, it is called "operator precedence"
CodePudding user response:
1st adding ()
2nd change df
to df1
out = df1[ (df1['starts']<df1['ends']) & (df1['starts'].shift(-1)>=df1['ends']) ]
Out[410]:
starts ends
0 5 8
1 9 16
2 21 24
3 25 28
4 30 33
5 34 37