LoginSignup
0
1

More than 3 years have passed since last update.

DataFrameの1番楽で美しい作成方法

Last updated at Posted at 2021-04-26

今回はPandas初心者に向けて「結局どの書き方が一番美しいの??」という疑問を解消する。
〜feat.独断と偏見〜

パターン1

import pandas as pd
import numpy as np
a0 = np.array([1,2,3,4,5])
a1 = np.array(['北海道','秋田','岩手','沖縄','鹿児島'])
IKITEE = pd.DataFrame({
'数字':a0,
'場所':a1,
})
print(IKITEE)

パターン2

import pandas as pd
import numpy as np
IKITEE = pd.DataFrame(
{'数字':[1,2,3,4,5],
'場所':['北海道','秋田','岩手','沖縄','鹿児島']},
columns = ['数字','場所'])
print(IKITEE)

こんな感じです。

0
1
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
1