In [5]:
import pandas as pd

data = pd.read_csv("../../season_1_sad/training_data/weather_data/weather_data_2016-01-06.csv")
data = data.drop_duplicates(["time"])
data.reset_index(drop=True,inplace=True)

print(data.columns)

date = data["date"].unique()[0]
week = data["week"].unique()[0]


dict1 = dict(zip(data.time,data.Weather))
dict2 = dict(zip(data.time,data["PM2.5"]))
dict3 = dict(zip(data.time,data["temperature"]))


Index(['Weather', 'temperature', 'PM2.5', 'week', 'date', 'time'], dtype='object')

In [6]:
df = pd.DataFrame(columns=["time","Weather","PM2.5","date","week"])
df["time"]=pd.Series(range(1,145))
df["Weather"]=0
df["PM2.5"]=0
df["temperature"]=0
df["date"] = date
df["week"] = week
default_wea = 0
default_pm = 0
default_tem = 0
for x in df["time"]:
    default_wea = dict1.get(x,default_wea)
    default_pm = dict2.get(x,default_pm)
    default_tem = dict3.get(x,default_tem)
   
    
    df["Weather"] = df["Weather"].set_value(int(x)-1,default_wea)
    df["PM2.5"] = df["PM2.5"].set_value(int(x)-1,default_pm)
    df["temperature"] =  df["temperature"].set_value(int(x)-1,default_tem)

In [7]:
for x in df["time"]:
    if(x>2 and x<143):
      
        s1=df["Weather"][int(x)-1]
        s2=df["Weather"][int(x)+1]
        if(s1 == s2):
            df["Weather"][x]=s1
        else:
            pass
    else:
        pass
    
print(df)


/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/ipykernel/__main__.py:7: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
     time  Weather  PM2.5        date  week  temperature
0       1        4     53  2016-01-06     3            8
1       2        4     53  2016-01-06     3            8
2       3        4     53  2016-01-06     3            8
3       4        4     53  2016-01-06     3            8
4       5        4     56  2016-01-06     3            8
5       6        8     56  2016-01-06     3            8
6       7        8     56  2016-01-06     3            8
7       8        8     56  2016-01-06     3            8
8       9        8     56  2016-01-06     3            8
9      10        8     56  2016-01-06     3            8
10     11        3     55  2016-01-06     3            8
11     12        3     55  2016-01-06     3            8
12     13        3     55  2016-01-06     3            8
13     14        3     55  2016-01-06     3            8
14     15        3     55  2016-01-06     3            8
15     16        3     55  2016-01-06     3            8
16     17        3     55  2016-01-06     3            8
17     18        3     45  2016-01-06     3            8
18     19        3     45  2016-01-06     3            8
19     20        3     45  2016-01-06     3            7
20     21        3     45  2016-01-06     3            7
21     22        3     45  2016-01-06     3            7
22     23        3     42  2016-01-06     3            7
23     24        3     42  2016-01-06     3            7
24     25        4     42  2016-01-06     3            7
25     26        4     42  2016-01-06     3            7
26     27        4     42  2016-01-06     3            7
27     28        4     42  2016-01-06     3            7
28     29        4     42  2016-01-06     3            7
29     30        4     42  2016-01-06     3            7
..    ...      ...    ...         ...   ...          ...
114   115        4     85  2016-01-06     3            8
115   116        4     85  2016-01-06     3            8
116   117        4     85  2016-01-06     3            8
117   118        4     85  2016-01-06     3            8
118   119        4     88  2016-01-06     3            8
119   120        4     88  2016-01-06     3            8
120   121        4     88  2016-01-06     3            8
121   122        4     88  2016-01-06     3            8
122   123        4     88  2016-01-06     3            8
123   124        4     88  2016-01-06     3            8
124   125        4     93  2016-01-06     3            8
125   126        4     93  2016-01-06     3            8
126   127        4     93  2016-01-06     3            8
127   128        4     93  2016-01-06     3            7
128   129        4     93  2016-01-06     3            7
129   130        4     93  2016-01-06     3            7
130   131        4     93  2016-01-06     3            7
131   132        4     93  2016-01-06     3            7
132   133        4     93  2016-01-06     3            7
133   134        4     93  2016-01-06     3            7
134   135        4     93  2016-01-06     3            7
135   136        4     93  2016-01-06     3            7
136   137        4     93  2016-01-06     3            7
137   138        4     93  2016-01-06     3            7
138   139        4     93  2016-01-06     3            7
139   140        4     93  2016-01-06     3            7
140   141        4     93  2016-01-06     3            7
141   142        4     93  2016-01-06     3            7
142   143        4     93  2016-01-06     3            8
143   144        4     93  2016-01-06     3            8

[144 rows x 6 columns]

In [15]:
plot_single_day_weather(df)


In [ ]:


In [ ]:


In [ ]:


In [ ]: