I have monthly dataframe (df) that is already in min - max ranges like the below:
Wind Jan Feb Nov Dec calib
West 0.1-25.5 2.8-65.3 1.3-61.3 0.9-35.3 50
North 0.2-28.3 3.1-66.4 1.0-67.7 1.9-40.1 60
South 0.3-29.5 2.5-49.4 1.9-63.4 0.3-33.0 60
East 20.5 1.1-41.1 0.9-40.3 nan 50
I want to know the number of times the max wind speed was below the calib number each month. So I am trying to create a column Speed below calib (sbc) like below.
month_col = ['Jan', 'Feb', 'Nov', 'Dec']
df['sbc'] = (pd.to_numeric(df[month_col].str.extract(r"(?<=-)(\d+\.\d+)")) < df["calib"]).sum(axis=1)
The above code is not working and I am getting the error AttributeError: 'DataFrame' object has no attribute 'str'. How would I fix this?