LoginSignup
0
2

More than 3 years have passed since last update.

PandasのDataFrameを二重リストから作成する&CSVに書きだす

Last updated at Posted at 2021-04-16

二重リストからDataFrameを作成する(カラム名を指定)

import pandas as pd
import numpy as np

data = np.arange(12).reshape(3, 4)
df_simple = pd.DataFrame(data, columns=['col_0', 'col_1', 'col_2', 'col_3'])

print(df_simple)
#    col_0  col_1  col_2  col_3
#0      0      1      2      3
#1      4      5      6      7
#2      8      9     10     11

DataFrameをCSVに書き出す(indexなしでエンコードを指定して)

df_simple.to_csv("df_simple.csv", encoding="utf-8-sig", index = False)
0
2
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
2