ARTICLE AD BOX
I work with Pandas, which is the project I'm currently working on.
This is the dataframe:
property_type place_with_parent_names region lat-lon area_m2 price_usd lat lon 0 apartment |Brasil|Alagoas|Maceió| Northeast -9.6443051,-35.7088142 110.0 $187,230.85 -9.6443051 -35.7088142 1 apartment |Brasil|Alagoas|Maceió| Northeast -9.6430934,-35.70484 65.0 $81,133.37 -9.6430934 -35.70484 2 house |Brasil|Alagoas|Maceió| Northeast -9.6227033,-35.7297953 211.0 $154,465.45 -9.6227033 -35.7297953 3 apartment |Brasil|Alagoas|Maceió| Northeast -9.622837,-35.719556 99.0 $146,013.20 -9.622837 -35.719556 4 apartment |Brasil|Alagoas|Maceió| Northeast -9.654955,-35.700227 55.0 $101,416.71 -9.654955 -35.700227I try to divide the "place_with_parent_names" to 3 columns ("country", "state", "city").
This is the code:
df1[["country", "state", "city"]] = df1['place_with_parent_names'].str.split("|", expand=True);But, I get this error:
ValueError: Columns must be same length as key
