|
52 | 52 | "source": [ |
53 | 53 | "# read the csv\n", |
54 | 54 | "# specify delimiter, fix encoding, parse the date(day first format), use the column of date as row index\n", |
55 | | - "fixed_df = pd.read_csv('data/bikes.csv', sep=';', encoding='latin1', parse_dates=['Date'], dayfirst=True, index_col='Date')" |
56 | | - ] |
57 | | - }, |
58 | | - { |
59 | | - "cell_type": "code", |
60 | | - "execution_count": 5, |
61 | | - "metadata": { |
62 | | - "collapsed": false |
63 | | - }, |
64 | | - "outputs": [ |
65 | | - { |
66 | | - "data": { |
67 | | - "text/html": [ |
68 | | - "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n", |
69 | | - "<table border=\"1\" class=\"dataframe\">\n", |
70 | | - " <thead>\n", |
71 | | - " <tr style=\"text-align: right;\">\n", |
72 | | - " <th></th>\n", |
73 | | - " <th>Berri 1</th>\n", |
74 | | - " <th>Brébeuf (données non disponibles)</th>\n", |
75 | | - " <th>Côte-Sainte-Catherine</th>\n", |
76 | | - " <th>Maisonneuve 1</th>\n", |
77 | | - " <th>Maisonneuve 2</th>\n", |
78 | | - " <th>du Parc</th>\n", |
79 | | - " <th>Pierre-Dupuy</th>\n", |
80 | | - " <th>Rachel1</th>\n", |
81 | | - " <th>St-Urbain (données non disponibles)</th>\n", |
82 | | - " </tr>\n", |
83 | | - " <tr>\n", |
84 | | - " <th>Date</th>\n", |
85 | | - " <th></th>\n", |
86 | | - " <th></th>\n", |
87 | | - " <th></th>\n", |
88 | | - " <th></th>\n", |
89 | | - " <th></th>\n", |
90 | | - " <th></th>\n", |
91 | | - " <th></th>\n", |
92 | | - " <th></th>\n", |
93 | | - " <th></th>\n", |
94 | | - " </tr>\n", |
95 | | - " </thead>\n", |
96 | | - " <tbody>\n", |
97 | | - " <tr>\n", |
98 | | - " <th>2012-01-01</th>\n", |
99 | | - " <td> 35</td>\n", |
100 | | - " <td>NaN</td>\n", |
101 | | - " <td> 0</td>\n", |
102 | | - " <td> 38</td>\n", |
103 | | - " <td> 51</td>\n", |
104 | | - " <td> 26</td>\n", |
105 | | - " <td> 10</td>\n", |
106 | | - " <td> 16</td>\n", |
107 | | - " <td>NaN</td>\n", |
108 | | - " </tr>\n", |
109 | | - " <tr>\n", |
110 | | - " <th>2012-01-02</th>\n", |
111 | | - " <td> 83</td>\n", |
112 | | - " <td>NaN</td>\n", |
113 | | - " <td> 1</td>\n", |
114 | | - " <td> 68</td>\n", |
115 | | - " <td> 153</td>\n", |
116 | | - " <td> 53</td>\n", |
117 | | - " <td> 6</td>\n", |
118 | | - " <td> 43</td>\n", |
119 | | - " <td>NaN</td>\n", |
120 | | - " </tr>\n", |
121 | | - " <tr>\n", |
122 | | - " <th>2012-01-03</th>\n", |
123 | | - " <td> 135</td>\n", |
124 | | - " <td>NaN</td>\n", |
125 | | - " <td> 2</td>\n", |
126 | | - " <td> 104</td>\n", |
127 | | - " <td> 248</td>\n", |
128 | | - " <td> 89</td>\n", |
129 | | - " <td> 3</td>\n", |
130 | | - " <td> 58</td>\n", |
131 | | - " <td>NaN</td>\n", |
132 | | - " </tr>\n", |
133 | | - " </tbody>\n", |
134 | | - "</table>\n", |
135 | | - "</div>" |
136 | | - ], |
137 | | - "text/plain": [ |
138 | | - " Berri 1 Brébeuf (données non disponibles) Côte-Sainte-Catherine \\\n", |
139 | | - "Date \n", |
140 | | - "2012-01-01 35 NaN 0 \n", |
141 | | - "2012-01-02 83 NaN 1 \n", |
142 | | - "2012-01-03 135 NaN 2 \n", |
143 | | - "\n", |
144 | | - " Maisonneuve 1 Maisonneuve 2 du Parc Pierre-Dupuy Rachel1 \\\n", |
145 | | - "Date \n", |
146 | | - "2012-01-01 38 51 26 10 16 \n", |
147 | | - "2012-01-02 68 153 53 6 43 \n", |
148 | | - "2012-01-03 104 248 89 3 58 \n", |
149 | | - "\n", |
150 | | - " St-Urbain (données non disponibles) \n", |
151 | | - "Date \n", |
152 | | - "2012-01-01 NaN \n", |
153 | | - "2012-01-02 NaN \n", |
154 | | - "2012-01-03 NaN " |
155 | | - ] |
156 | | - }, |
157 | | - "execution_count": 5, |
158 | | - "metadata": {}, |
159 | | - "output_type": "execute_result" |
160 | | - } |
161 | | - ], |
162 | | - "source": [ |
| 55 | + "fixed_df = pd.read_csv('data/bikes.csv', sep=';', encoding='latin1', parse_dates=['Date'], dayfirst=True, index_col='Date')\n", |
163 | 56 | "fixed_df[:3]" |
164 | 57 | ] |
165 | 58 | }, |
|
0 commit comments