pythonpandaswindrose

Python/Pandas: No counting records above certain value


I am trying to make a windrose from Excel data and I need to skip all values bigger than 10 for velocity. The data range is from 0 to 17 and I only want values from 0 to 10 showing on the windrose. How can I achieve that?

import pandas as pd
from windrose import WindroseAxes

df = pd.read_excel(r'sheet')

ax = WindroseAxes.from_ax()
ax.bar(df.Dir, df.Vel, normed=True, opening=0.8, edgecolor='white')
ax.set_legend(loc="upper right")

Solution

  • You can filter out all velocities more than 10.(This won't change the excel file )

    import pandas as pd
    from windrose import WindroseAxes
    
    # I have not seen this way of reading excel files. I thought you would need an engine 
    df = pd.read_excel(r'sheet')
    
    # filter out values greater than 10 for velocity and reset the index
    df = df.loc[df['Vel'] <= 10].reset_index(drop=True)
    
    ax = WindroseAxes.from_ax()
    ax.bar(df.Dir, df.Vel, normed=True, opening=0.8, edgecolor='white')
    ax.set_legend(loc="upper right")