오늘의 인기 글
최근 글
최근 댓글
Today
Total
05-20 00:00
관리 메뉴

우노

[Python] Pandas DataFrame column에 numpy 배열 추가하기 본문

Language/Python

[Python] Pandas DataFrame column에 numpy 배열 추가하기

운호(Noah) 2021. 1. 14. 10:41
import numpy as np

# dataframe 생성
data = np.array([[1,4],[2,5],[3,6]])
df = pd.DataFrame(data, columns=['col1','col2'])
#   col1    col2
#0      1        4
#1      2        5
#2      3        6

# dataframe에 numpy 배열 추가
col3 = np.array([7,8,9])
df['col3'] = col3
#   col1    col2    col3
#0      1       4       7
#1      2       5       8
#2      3       6       9
Comments