我需要在循环中将浮点数更改为%值。问题是当我尝试这样做时,在循环的第二个值中,原始数据更改为str而不是float。
for item in correccion_kpis:
status_general.loc[status_general[header_tracker_KPI] == item, \
header_final_kpi] = (status_general[header_final_kpi] * 100).map('{:,.2f}%'.format)
status_general.loc[status_general[header_tracker_KPI] == item, \
header_tracker_KPI_Objetivo] = status_general[header_tracker_KPI_Objetivo].map('{:,.2f}%'.format)
status_general.loc[status_general[header_tracker_KPI] == item, \
header_final_kpi_dia_anterior] = (status_general[header_final_kpi_dia_anterior] * 100).map('{:,.2f}%'.format)
error: ValueError: Unknown format code 'f' for object of type 'str'