Here is my question.
I have one dataframe df which contain two columns named date and wd.
And the wd means the wind direction which range from (0~360).
So, the df represent the wind direction of somewhere in certain time frame.
I want to classify those wind direction into 16 classes like this:
http://7xrn7f.com1.z0.glb.clouddn.com/16-3-8/30080798.jpg
The ranges are presented here.
http://7xrn7f.com1.z0.glb.clouddn.com/16-3-8/8398960.jpg
This is what I can deal with now:
wd_stat = []
for i in range(0,len(df),1):
wd = df.wd.iloc[i]
### NNE 11.25-33.75
if 11.25 <= wd < 33.75:
wd_stat.append("NNE")
### NE 33.75-56.25
if (33.75 <=wd < 56.25):
wd_stat.append("NE")
### ENE 56.25 - 78.75
if (56.25 <=wd < 78.75):
wd_stat.append("ENE")
if (78.75 <=wd < 101.25):
wd_stat.append("E")
if (101.25 <=wd < 123.75):
wd_stat.append("ESE")
.....not done yet......
My method was inflexible and dump.
Can anyone give some advices to deal the classify problem like this(number range into certain characters) in high efficience.