1
import pandas as pd
import collections
df = pd.DataFrame(columns=['a','b','c','d'])
counter = collections.Counter({'a':1, 'b':2})
Was ich will ist counter
zu df
so tun, legen Sie, dass das Ergebnis so sein würde:Python: Wie Counter-Objekt zu Dataframe hinzufügen?
a b c d
0 1 2 0 0
Wie kann ich das tun?
Danke, aber ist es eine Möglichkeit, es 'inplace = True auszuführen' – user3595632
Es scheint nicht so. Vielleicht 'df = df.append (counter, ignore_index = True) .fillna (0)'. Nicht "inplace" obwohl. – Psidom
'inplace = True 'tut nicht wirklich viel (http://stackoverflow.com/a/22533110/487339). – DSM