I have the following code
df2['TaxAccNo4'] = df2['TaxAccNo2'].apply(lambda x: x.split('.')[0])
df2['TaxAccNo3'] = df2['TaxAccNo2'].apply(lambda x: x.split('.')[1])
where df2 is:
TaxAccNo2
0 00001379.1
1 00182218
When I run the code I get
TaxAccNo2 TaxAccNo4
0 00001379.1 00001379
1 00182218 00182218
and IndexError: list index out of range for TaxAccNo3,
TaxAccNo2 TaxAccNo4 TaxAccNo3
0 00001379.1 00001379 1
1 00182218 00182218
How do I fix my code to produce that output? I'm assuming its giving me the error because Index 1 doesn't have '.' but I'm not sure how to fix that.