len('17.21') > 4
data_new2['TYPE_NEW']= np.where(data_new2['TYPE']>
import pandas as pd
def f(row):
if len(row['TYPE'])>4 :
rt = row['TYPE'][0:5]
else:
rt = row['TYPE']
return rt
df=pd.DataFrame({'TYPE':('17.21' ,'47.75.1','68.20.2')})
df['TYPE_NEW'] = df.apply(f, axis=1)
TYPE TYPE_NEW
0 17.21 17.21
1 47.75.1 47.75
2 68.20.2 68.20