How would I go about adding a row to the top of this dataframe. This is downloaded data. I cannot use a specific row index in the formula because the first Datetime indice changes all the time. I cannot also use a specific label for the inner index as it could be Datetime. Is there a way to generalize this?日時マルチインデックスパンダDATAFRAME
I tried this
df[df.index.min()[0])) - dt.timedelta(minutes=5), :] = [list to add]
however it only add a row at the end of the Dataframe. Sorting,
df.sort_index(inplace=True)
did not help because I guess I am dealing with 2 levels of index here; which would explain why the row sticks to the bottom of the frame.
A B C D E
2006-04-28 00:00:00
A 69.62 69.62 6.518 65.09 69.62
B
C
2006-05-01 00:00:00
A 71.5 71.5 6.522 65.16 71.5
B
C
2006-05-02 00:00:00
A 72.34 72.34 6.669 66.55 72.34
B
C
に行を追加する方法を最終的な結果は次のようになります。リストの要素であること X
年代を/配列を追加する。私にとって
A B C D E
NEWROW X1 X2 X3 X4 X5
2006-04-28 00:00:00
A 69.62 69.62 6.518 65.09 69.62
B
C
2006-05-01 00:00:00
A 71.5 71.5 6.522 65.16 71.5
B
C
2006-05-02 00:00:00
A 72.34 72.34 6.669 66.55 72.34
B
C
こんにちはjezrael :)、ありがとう!しかし、私はこれを得る:KeyError: 'MultiIndex Slicingは完全にlexsorted tuple len(2)、lexsort depth(1)'を必要とする ' – uniXVanXcel
最初に 'sort_index()'を試してみる。 – jezrael
あなたはもう一度やった!:)) – uniXVanXcel