Created
February 2, 2020 16:34
-
-
Save abbasali-io/ec48da520c277d369138b524c101828f to your computer and use it in GitHub Desktop.
Split the Built Up Type & Built Up Area Size into two separate columns, i.e. Built_Type & Built_Size, and show the top 5 rows of the dataframe to view the effect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define the function to split Size into an array of two differnt values | |
def split_property_size(size, tp=0): | |
try: | |
return size.split(":")[tp].strip() | |
except AttributeError: | |
return size | |
#create a new column with the buildup type | |
df["Built_Type"] = df['Size'].astype(str).apply(split_property_size, tp=0) | |
df["Built_Type"].value_counts(dropna=False) | |
df["Built_Size"] = df['Size'].apply(split_property_size, tp=1) | |
df["Built_Size"].value_counts(dropna=False) | |
df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment