0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pandasのDataFrameの列の追加

Posted at

列の追加

df = pd.DataFrame([], columns=['col1', 'col2', 'col3']) #空のを作成
for i in range(3):
  df2 = pd.DataFrame([[i, i, i]], columns=['col1', 'col2', 'col3'], index=["row" + str(i+1)])
  df = df.append(df2)

#     col1 col2 col3
# row1    0    0    0
# row2    1    1    1
# row3    2    2    2
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?