Extract second character from string in Python
Solution 1:
Use str.split
and keep the second element with str[1]
:
df['type1'] = df['type'].str.split('-').str[1]
print(df)
# Output
type stat type1
0 SSS-AA-11111 y AA
1 FFF-BB-22222 y BB