Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extract first letter of column python

df['new_col'] = df['First'].astype(str).str[0]
df

Out[29]:
   First  Second new_col
0    123     234       1
1     22    4353       2
2     32     355       3
3    453     453       4
4     45     345       4
5    453     453       4
6     56      56       5
 
PREVIOUS NEXT
Tagged: #extract #letter #column #python
ADD COMMENT
Topic
Name
6+8 =