Я пытаюсь получить предыдущее значение строки в кадре данных. Не могли бы вы помочь мне, как это сделать?
пример:
Dataframe:
and_or_not_oprtor
NULL
AND
OR
NULL
код
for index, row in df.iterrows():
if row['and_or_not_oprtor'] == None and row['operator_type'] == '=' and row['and_or_not_oprtor'].shift(1) == 'AND':
case_stmnt = str(row['operator_type']) + "'" +str(row['input_value']) + "'" + ' ' + 'THEN' + ' ' + "'" + str(row['output_value']) + "'" + ' '
elif row['and_or_not_oprtor'] == None and row['operator_type'] == '=':
#print('shiv')
case_stmnt += 'WHEN' + str(row['operator_type']) + "'" +str(row['input_value']) + "'" + ' ' + 'THEN' + ' ' + "'" + str(row['output_value']) + "'" + ' '
ошибка:
'NoneType' object has no attribute 'shift'