I have a dataframe ('sp500news') which looks like the following:
date_publish \
79944 2007-01-29 19:08:35
181781 2007-12-14 19:39:06
213175 2008-01-22 11:17:19
93554 2008-01-22 18:52:56
...
title
79944 Microsoft Vista corporate sales go very well
181781 Williams No Anglican consensus on Episcopal Church
213175 CSX quarterly profit rises
93554 Citigroup says 30 bln capital helps exceed target
...
I am trying to update each company name with its corresponding ticker from a the 'symbol' column of df ('constituents') which looks like:
Symbol Name Sector
0 MMM 3M Industrials
1 AOS A.O. Smith Industrials
2 ABT Abbott Health Care
3 ABBV AbbVie Health Care
...
116 C Citigroup Financials
...
I've already tried:
for item in sp500news['title']:
for word in item:
if word in constituents['Name']:
indx = constituents['Name'].index(word)
str.replace(word, constituents['Symbol'][indx])