|
122 | 122 | " os.path.dirname(__file__))[0], 'example')\n", |
123 | 123 | " file = os.path.join(kwargs['datapath'], filename)\n", |
124 | 124 | " # read csv file \n", |
125 | | - " weather_df = pd.read_csv(file, index_col=0, header=[0, 1])\n", |
| 125 | + " weather_df = pd.read_csv(\n", |
| 126 | + " file, index_col=0, header=[0, 1],\n", |
| 127 | + " date_parser=lambda idx: pd.to_datetime(idx, utc=True))\n", |
126 | 128 | " # change type of index to datetime and set time zone\n", |
127 | | - " weather_df.index = pd.to_datetime(weather_df.index).tz_localize(\n", |
128 | | - " 'UTC').tz_convert('Europe/Berlin')\n", |
| 129 | + " weather_df.index = pd.to_datetime(weather_df.index).tz_convert(\n", |
| 130 | + " 'Europe/Berlin')\n", |
129 | 131 | " # change type of height from str to int by resetting columns\n", |
130 | 132 | " weather_df.columns = [weather_df.axes[1].levels[0][\n", |
131 | | - " weather_df.axes[1].labels[0]],\n", |
| 133 | + " weather_df.axes[1].codes[0]],\n", |
132 | 134 | " weather_df.axes[1].levels[1][\n", |
133 | | - " weather_df.axes[1].labels[1]].astype(int)]\n", |
| 135 | + " weather_df.axes[1].codes[1]].astype(int)]\n", |
134 | 136 | " return weather_df\n", |
135 | 137 | "\n", |
136 | 138 | "\n", |
|
0 commit comments