■ concat 함수를 사용해 UNION ALL 데이터를 만드는 방법을 보여준다.
▶ main.py
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import pandas as pd dataFrame1 = pd.DataFrame( { "city" : ["Chicago", "San Francisco", "New York City"], "rank" : range(1, 4) } ) print(dataFrame1) """ city rank 0 Chicago 1 1 San Francisco 2 2 New York City 3 """ print() dataFrame2 = pd.DataFrame( { "city" : ["Chicago", "Boston", "Los Angeles"], "rank" : [1, 4, 5] } ) print(dataFrame2) """ city rank 0 Chicago 1 1 Boston 4 2 Los Angeles 5 """ print() dataFrame3 = pd.concat([dataFrame1, dataFrame2]) print(dataFrame3) """ city rank 0 Chicago 1 1 San Francisco 2 2 New York City 3 0 Chicago 1 1 Boston 4 2 Los Angeles 5 """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 |
numpy==2.1.2 pandas==2.2.3 python-dateutil==2.9.0.post0 pytz==2024.2 six==1.16.0 tzdata==2024.2 |
※ pip install pandas 명령을 실행했다.