파이썬(Python)/Pandas

pandas dataframe에 row 추가하기

leebaro 2021. 2. 3.
728x90
  mem_no prd_no
0 100 1000
1 200 2000

 

위와 같은 df라는 이름의 DataFrame이 있을 때 한 행을 추가하고 싶을 수 있다. 이 때는 아래와 같이 진행하면 된다.

 

import pandas as pd
list1 = [300, 3000]
df2 = df.append(pd.Series(list1, index=df.columns), ignore_index=True)

df2

위와 같이 처리하면 한 행이 추가된 것을 확인할 수 있다.

 

 


참고

emilkwak.github.io/dataframe-list-row-append-ignore-index

728x90