out_df['# of Days'] = out_df['# of Days'].replace('',1)
out_df['# of Days'] += 1
print(out_df)
除非单元格的值为 NULL,否则它不会添加 1 值。
尝试将 1 添加到整个列,包括列中的空单元格。
def newValue(value):
if value == "":
return 1
if value is None:
return 1
return value + 1
out_df['# of Days'] = newValue(out_df['# of Days'])