νμ΄μ λ°μ΄ν° νλ μ ν¬λ‘€λ§νλ©΄μ, μ μ©νκ³ νμνλ ν¨μλ₯Ό μ΄μΌκΈ°νλ©΄,
νλ€μ€ λͺ¨λμμλ νΉνλ λ°μ΄ν°νλ μμ λ§λ€κ³ , μ μ₯νκ³ , ν©μΉκ³ λ κ²μ λ§μ΄ νμλλ°,
무μλ³΄λ€ ν©μΉλ μμ μ΄ λ§μλ€.
μλνλ©΄ κ° νμ΄μ§λ§λ€ νμ±ν λ°μ΄ν°λ€μ νλμ λ°μ΄ν°νλ μμΌλ‘ λ§λ€μ΄λκ³ , κ·Έλκ·Έλλ§λ€ λ°μ΄ν°νλ μμ νμ±νμ¬, κΈ°μ‘΄μ νμ κ³μν΄μ ν©μΉλ λ°©μμΌλ‘ νμκΈ° λλ¬Έμ΄λ€.
κΈ°μ‘΄μ 리μ€νΈμλ€κ° κΎΈμ€ν appendλ₯Ό ν΅ν΄ λ£μ΄μ νλ²μ ν μλ μμ§λ§, κ·Έλ κ² λλ©΄, λ¨μ μ λ§μ½μ μ€κ°μ μμ μ΄ λ©μΆκ±°λ νλ©΄, ν΄λΉ 리μ€νΈμ κ°μ μ μ₯λμ΄ μμ§λ§, μΌλ§λ μ μ₯λμ΄ μλμ§, κΈΈμ΄λ λ§λμ§μ λν νμΈμμ μ΄ μ΄λ ΅κ³ , μ¬μ€μ λ€μ μμνμ¬μΌν μλ μλ€κ³ νλ¨νλ€.
κ·Έλμ νλ€μ€ pandas μ pd.concat() λ₯Ό λ§μ΄ μ¬μ©νμλ€.
# λ°μ΄ν° νλ μ λ§λ€κΈ°
# μμ λ°μ΄ν° νλ μ(νμ΄μ§ λ§λ€)
temp_df = pd.DataFrame(
columns = ['carName','modelName','fuel','autoManual',
'colors','years','years','miles','prices','dates'])
temp_df['carName'] = carName
temp_df['modelName'] = modelName
temp_df['fuel'] = fuel
temp_df['autoManual'] = autoManual
temp_df['colors'] = colors
temp_df['years'] = years
temp_df['miles'] = miles
temp_df['prices'] = prices
temp_df['dates'] = dates
# μ 체 λ°μ΄ν° νλ μμ κ³μν΄μ λν΄μ£Όλ ꡬ쑰
origin_df = pd.concat([origin_df, temp_df])
κΈ°μ‘΄μ λ°μ΄ν°νλ μμ origin_df μ΄λ€.
κ·Έλ¦¬κ³ κ° νμ΄μ§λ§λ€ νμ±ν λ°μ΄ν°λ€μ νλμ λ°μ΄ν°νλ μμΌλ‘ λ§λ€μ΄λλ μμμ df λ temp_df μ΄λ€.
df_a μ df_b λ₯Ό ν©μΉλ©΄ λ€μκ³Ό κ°λ€.
pd.concat([df_a,df_b])
pd.concat μμ ignore_index = True λ‘ νλ κ²½μ°, μλ‘κ² 0λΆν° μμ°¨μ μΌλ‘ μΈλ±μ€κ° νμ±μ΄ λλ€.
μ¬κΈ°μ default κ°μ ignore_index = False μΈ κ²κ³Ό κ°λ€
'ποΈμννΈμ¨μ΄ > π»python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
'list' object has no attribute 'find_all' μλ¬ (0) | 2021.11.25 |
---|---|
[Python] TypeError: 'NoneType' object is not iterable μ€λ₯ ν΄κ²° λ°©λ² (0) | 2021.11.25 |
[python] ν¬λ‘€λ§ implicit wait vs time.sleep (0) | 2021.11.25 |
[python] ν¬λ‘€λ§μ νμν ν¨μ : filter, lambda, map (0) | 2021.11.25 |
python μ½λ μκ° κ³μ° (0) | 2021.11.24 |