I have a dataframe like as shown below
df = pd.DataFrame({'val': ['test','depat','23.1','25.0','31',np.nan]})
I would like to crete two new columns val_num and val_string
In val_num, I would like to store numeric/int values
In val_string, I would like to store string values
So, I tried the below
df['val_num'] = pd.to_numeric(df['val'],errors='coerce')
df['val_string'] = (df[pd.to_numeric(df['val'],errors='coerce').isna()])
Though the above works fine, is there any elegant function like to_numeric for identifying string objects using to_string?