python - how to add new record to pandas dataframe -
python - how to add new record to pandas dataframe -
i add together new records new indices pandas dataframe example:
df = pandas.dataframe(columns = ['col1', 'col2'])
now have new record, index label 'test1', , values [20, 30] (pseudo code):
df.append(index='test1', [20, 30])
so result be
col1 col2 test1 20 30
the furthest i've reached was:
df = df.append({'col1':20, 'col2':30}, ignore_index=true)
but solution not includes new index
thanks!
you can utilize .ix:
in [1]: df = pd.dataframe(columns = ['col1', 'col2']) in [2]: df.ix['test1'] = [20, 30] in [3]: df out[3]: col1 col2 test1 20 30 [1 rows x 2 columns]
python pandas
Comments
Post a Comment