Skip to content

Instantly share code, notes, and snippets.

@utahka
Created September 18, 2017 07:32
Show Gist options
  • Save utahka/367704b5ef4500048ade72d03ee06886 to your computer and use it in GitHub Desktop.
Save utahka/367704b5ef4500048ade72d03ee06886 to your computer and use it in GitHub Desktop.
空のデータフレームを作って、レコードを追加していくパターン
import pandas as pd
cols = ['col1', 'col2']
df = pd.DataFrame(index=[], columns=cols)
record = pd.Series(['hoge', 'fuga'], index=df.columns)
for _ in range(5):
df = df.append(record, ignore_index=True)
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment