I have a pandas DataFrame which has 3 digits (string) such as '001' , '010' and '121'. I would like to replace any 1 digit and any 2 digit strings such as '001' , and '010' with just '1' and '10'.
How can I do this? I tried using the apply method (see below) but nothing changes.
df.ZIPCOUNTY_CA is the pandas dataframe and 'county code' is the column which has these string digits.
df_ZIPCOUNTY_CA[df_ZIPCOUNTY_CA['county code'].str.startswith('0')]['county codes'] = df_ZIPCOUNTY_CA[df_ZIPCOUNTY_CA['county code'].str.startswith('0')]['county code'].apply(lambda x: x.split('0')[1])