1 回答
TA贡献1909条经验 获得超7个赞
如果问题基本上是关于在数据框中插入另一个时间列,这将是一个解决方案:
import pandas as np
df = pd.DataFrame({'toto': ["A", "B", "C", "D"],
'titi': ["g", "t", "x", "z"],
'Energy': [180, 345, 234, 654],
'T10sec': [0.1, 0.4, 0.5, 1],
'T50sec': [5.3, 5.7, 8, 2]})
df
toto titi Energy T10sec T50sec
0 A g 180 0.1 5.3
1 B t 345 0.4 5.7
2 C x 234 0.5 8.0
3 D z 654 1.0 2.0
添加时间栏:
import numpy as np
time = 'T15sec'
if not time in df:
df[time] = np.NaN
df.iloc[:, 3:] = df.iloc[:, 3:].T.sort_index().interpolate().T
df[['toto', 'titi', 'Energy', 'T10sec', time, 'T50sec']]
toto titi Energy T10sec T15sec T50sec
0 A g 180 0.1 2.70 5.3
1 B t 345 0.4 3.05 5.7
2 C x 234 0.5 4.25 8.0
3 D z 654 1.0 1.50 2.0
添加回答
举报