对于那些不知道的人,这里是TSFresh可以消化的数据集的正确格式:
id time F_x F_y F_z T_x T_y T_z
0 1 0 -1 -1 63 -3 -1 0
1 1 1 0 0 62 -3 -1 0
2 1 2 -1 -1 61 -3 0 0
3 1 3 -1 -1 63 -2 -1 0
4 1 4 -1 -1 63 -3 -1 0
现在这是我的数据集:
我希望我的所有日期都是上面数据框中的'时间',我的共同资金将是'id'。我的第一个想法是使用pd.melt
以下代码:
testing2 = pd.melt(testing, id_vars= testing.index, value_vars=testing.columns.values)
产生以下数据帧:
我能够让id
和value
正确但日期不正确,我不知道如何解决这个问题。
非常感谢任何帮助。
编辑:原始数据
AABTX AACTX AADTX AAETX AAFTX AAGPX AAGTX AAHTX AAIPX AALTX ... VTSMX VTTHX VTTVX VTWNX VTWSX VTXVX WASAX WBIGX WMGAX YAFFX
Date
2012-09-04 -0.552505 -0.590357 -0.617835 -0.590901 -0.568813 -0.527866 -0.562506 -0.554169 -0.534142 -0.553560 ... -0.498664 -0.542211 -0.546897 -0.547675 -0.498821 -0.581834 -0.096870 -0.516713 -0.396338 -0.308581
2012-09-05 -0.552505 -0.593916 -0.620684 -0.593322 -0.571045 -0.530639 -0.564629 -0.556210 -0.532483 -0.555652 ... -0.499373 -0.543793 -0.548980 -0.550324 -0.502974 -0.585566 -0.108832 -0.514231 -0.401808 -0.307566
2012-09-06 -0.501743 -0.551211 -0.577949 -0.554581 -0.533099 -0.489973 -0.528536 -0.521516 -0.464490 -0.522179 ... -0.474196 -0.505818 -0.511480 -0.511913 -0.459360 -0.537058 -0.078529 -0.469567 -0.356951 -0.272033
2012-09-07 -0.486515 -0.536976 -0.563704 -0.540054 -0.521938 -0.479807 -0.517920 -0.511312 -0.429664 -0.509627 ... -0.468522 -0.491578 -0.494813 -0.497344 -0.440669 -0.514670 -0.054606 -0.442271 -0.339445 -0.271018
2012-09-10 -0.501743 -0.547652 -0.575100 -0.552160 -0.533099 -0.490897 -0.526413 -0.519475 -0.446248 -0.520087 ... -0.475969 -0.502654 -0.507313 -0.507940 -0.452092 -0.529596 -0.056998 -0.449715 -0.353668 -0.284216
2012-09-11 -0.486515 -0.536976 -0.566553 -0.542475 -0.524170 -0.478883 -0.520043 -0.513353 -0.413080 -0.511719 ... -0.472068 -0.493160 -0.496897 -0.499993 -0.438592 -0.518402 -0.052213 -0.434827 -0.353668 -0.280155
2012-09-12 -0.486515 -0.533417 -0.560855 -0.537632 -0.519706 -0.476110 -0.515797 -0.509271 -0.393180 -0.507535 ... -0.468522 -0.486831 -0.490647 -0.494695 -0.430285 -0.510939 -0.046631 -0.427383 -0.343821 -0.286246