Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Python :: python print dict pretty 
Python :: dropdown in tkinter 
Python :: django admin prefetch_related 
Python :: suffixes in pandas 
Python :: generate random string python 
Python :: plot model 
Python :: spacy stopwords 
Python :: how to open file in BeautifulSoup 
Python :: dataframe select entries that are in a list 
Python :: name unnamed column pandas 
Python :: get local timezone python 
Python :: how to play sound after pressing a button in tkinter 
Python :: how to remove coma in python 
Python :: python deep copy of a dictionary 
Python :: how to get all links text from a website python beautifulsoup 
Python :: PRINT VS RETURN IN PYTHON 
Python :: find duplicated rows with respect to multiple columns pandas 
Python :: os.execl(sys.executable, sys.executable, *sys.argv) 
Python :: python setup.py bdist_wheel did not run successfully 
Python :: display full dataframe pandas 
Python :: How do you sum consecutive numbers in Python? 
Python :: creating a 50 day and 100 day moving average python 
Python :: python find most occuring element 
Python :: pandas find top 10 values in column 
Python :: convert list of int to string python 
Python :: python pie chart with legend 
Python :: tkinter center frame 
Python :: python list ascii 
Python :: python print version python 
Python :: how to get data from json web api in python 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =