Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 날짜
- 리눅스
- flutter
- node.js
- pandas
- 유니티
- 다이어트
- PyQt
- MySQL
- port
- javascript
- Linux
- PER
- ubuntu
- mssql
- PyQt5
- MS-SQL
- ASP
- sqlite
- python
- IOS
- Excel
- Unity
- 함수
- swift
- 맛집
- 라즈베리파이
- urllib
- tensorflow
- GIT
Archives
아미(아름다운미소)
pandas concat 본문
import pandas as pd
# 예시: 둘 다 빈 DataFrame이지만 컬럼이 다름
df1 = pd.DataFrame(columns=['a', 'b'])
df2 = pd.DataFrame(columns=['b', 'c'])
# 👉 모든 컬럼의 합집합 구하기
all_columns = sorted(set(df1.columns).union(set(df2.columns)))
# 👉 컬럼 맞춰주기 (reindex로 없으면 NaN 채움)
df1 = df1.reindex(columns=all_columns)
df2 = df2.reindex(columns=all_columns)
# 👉 concat
result = pd.concat([df1, df2], ignore_index=True)
print(result)
Comments