I'm trying to convert the '-' string characters into np.nan whilst leaving the strings denoting negative floats/ints so that I can convert this into floats once removing the '-' characters which denote absent data.
I've tried using .applymap() for this as I want to apply this to the whole dataframe, but it doesn't work.
Here is the line of code:
dataframe.applymap(lambda x: None if (x[-1] == '-'))
Here is a sample of the dataframe:
Metric 2020 2019 2018 2017
Revenue Growth % 344.17 -14.88 107.11 -
Shares Change % 0.23 0 - -
Gross Margin % 87.7 84 89.3 84.9
Operating Margin % -17.1 -167.2 -42.2 -99.5