以下代码有效,但是当我向.format()添加格式时,出现错误...
test=['Interval: {} - {}<br>Best: {}<br>{}: {}'.format(
(pd.to_datetime(best_interval_df.loc[i].time_interval)) - timedelta(seconds=i),
(pd.to_datetime(best_interval_df.loc[i].time_interval)),
pd.to_datetime(best_interval_df.loc[i].datetime), 'Power',best_interval_df.loc[i]['best_power']) for i in best_interval_df.index]
['间隔:1970-01-01 00:46:12-1970-01-01 00:46:13
最佳:2018-05-15 16:44:33
电源: 581.0','间隔:1970-01-01 00:44:01-1970-01-01 00:44:03
最佳:2018-02-16 18:08:03
功率:560.0 ']
test=['Interval: {:%H:%M:%S} - {:%H:%M:%S}<br>Best: {:%Y-%m-%d}<br>{}: {:.0f}'.format(
(pd.to_datetime(best_interval_df.loc[i].time_interval)) - timedelta(seconds=i),
(pd.to_datetime(best_interval_df.loc[i].time_interval)),
pd.to_datetime(best_interval_df.loc[i].datetime), 'Power',best_interval_df.loc[i]['best_power']) for i in best_interval_df.index]
给出此错误: 在best_interval_df.index中,我的pd.to_datetime(best_interval_df.loc [i] .datetime),'Power',best_interval_df.loc [i] ['best_power']) TypeError:不支持的格式字符串传递给Series。格式