I have a dataframe, whose one particular column has temperature values like shown below
'35-40',
'35-40',
'40-45',
'40-45',
'45-50',
'40-45',
'40-45',
nan,
'40-45',
nan,
'40-45',
'40-45',
'35-40',
I am trying to create a new column separating minimum and maximum temperatures. In the rows filled with 'nan', I want the values after ',' to also be 'nan'. how should I do this? I have tried the code below but it didn't work.
train["Maximum Temperature"] = train["Cellar Temperature"].apply(lambda x: np.nan if train["Cellar Temperature"][0]==np.nan else (str(x).split("-")[1]))
Whenever I run the above code I get the following error
IndexError: list index out of range
Please help me.