바뀜

269 바이트 제거됨 ,  2022년 10월 19일 (수) 17:44
44번째 줄: 44번째 줄:  
|리스트를 가장 아래 행으로.
 
|리스트를 가장 아래 행으로.
 
|<syntaxhighlight lang="python">
 
|<syntaxhighlight lang="python">
df = df.append(pd.Series(list,  
+
# 붙이기 위해 리스트를 시리즈화 한다.
                        index=df.columns, # 기존 df의 컬럼 안에 들어가게끔.(이게 없으면 새 컬럼을 만들어버린다.)
+
a = pd.Series(item, index=df.columns) # index=df.columns이 없으면 새로운 열을 만들어 붙인다.
                        name='인덱스에 들어갈 내용'),
+
df = df.append(a,
                ignore_index=True  # 인덱스를 무시하고 df에 순차적으로 넣고 싶은 경우.
+
            ignore_index=True) # 인덱스를 무시하고 df에 순차적으로 넣고 싶은 경우.
                )
  −
# 또다른 방법.
  −
df = df.append(df.iloc[-1], ignore_index=True)  # 마지막 행을 하나 더 복사한다.
  −
df.iloc[-1] = list  # 마지막 자리에 리스트를 넣는다.
  −
print_df(df)
   
</syntaxhighlight>
 
</syntaxhighlight>
 
|}
 
|}