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