I am a python.new who need some help in the following question:
I got a dataframe like this.
df:
| index | height | unit |
|---|---|---|
| 0 | 181.5 | cm |
| 1 | 72.5 | inches |
| 2 | 168.0 | cm |
| 3 | NaN | NaN |
| .. | .. | .. |
...2000+rows
df = pd.DataFrame(data=[[181.5,'cm'],
[72.5,'inches'],
[168.0,'cm'],
['NaN','NaN']],
columns = ['height','unit'],
index=[1,2,3,4])
I want to unify the unit to "cm", and make corresponding changes to height, and keep the 'NaN's.