Replace NaN in one column with value from corresponding row of second column

Assuming your DataFrame is in df:

df.Temp_Rating.fillna(df.Farheit, inplace=True)
del df['Farheit']
df.columns="File heat Observations".split()

First replace any NaN values with the corresponding value of df.Farheit. Delete the 'Farheit' column. Then rename the columns. Here’s the resulting DataFrame:

    File  heat  Observations
0      1  YesQ            75
1      1   NoR           115
2      1  YesA            63
3      1   NoT            41
4      1   NoY            80
5      1  YesZ            12
6      2  YesQ           111
7      2   NoR            60
8      2  YesA            19
9      2   NoT            77
10     2   NoY            21
11     2  YesZ            54
12     3  YesQ            84
13     3   NoR            67
14     3  YesA            94
15     3   NoT            39
16     3   NoY            46
17     3  YesZ            81

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)