I have the following dataframe called df
country ticker
01 ST ENRO.ST
02 ST ERICb.ST
03 ST BTSb.ST
04 US MSFT
05 HK 0070.HK
06 ST SAABb.ST
07 ST SaA.ST
I want to do the following,
if the country == 'ST', select the string in the ticker row.
check if there are any lowercase characters.
If there is a lowercase character, add a hyphen before it and make the letter uppercase, like this.
country ticker
01 ST ENRO.ST
02 ST ERIC-B.ST
03 ST BTS-B.ST
04 US MSFT
05 HK 0070.HK
06 ST SAAB-B.ST
07 ST S-AA.ST
I would do the following if it was just one string,
teststr = [char for char in "ERICb.ST"]:
for i,v in enumerate(teststr):
if teststr[i].islower():
mod = i
teststr[mod] = teststr[mod].upper()
teststr.insert(mod,'-')
teststr = ''.join(teststr)
but i dont know how to apply it to every row if it meets that condition.