shimgo
9/12/2018 - 5:46 AM

pandasの空のDataFrameにデータを追加する

import pandas as pd

cols = ['col1', 'col2']
df = pd.DataFrame(index=[], columns=cols)

record = pd.Series(['foo', 'bar'], index=df.columns)

df = df.append(record, ignore_index=True)
df = df.append(record, ignore_index=True)
  
print(df)