|
132 | 132 | "outputs": [], |
133 | 133 | "source": [ |
134 | 134 | "%%sql\n", |
135 | | - "SELECT * \n", |
136 | | - " FROM comp.funda \n", |
| 135 | + "SELECT *\n", |
| 136 | + " FROM comp.funda\n", |
137 | 137 | " LIMIT 10\n" |
138 | 138 | ] |
139 | 139 | }, |
|
159 | 159 | "outputs": [], |
160 | 160 | "source": [ |
161 | 161 | "%%sql df01 <<\n", |
162 | | - "SELECT * \n", |
163 | | - " FROM comp.funda \n", |
| 162 | + "SELECT *\n", |
| 163 | + " FROM comp.funda\n", |
164 | 164 | " LIMIT 10\n" |
165 | 165 | ] |
166 | 166 | }, |
|
184 | 184 | "\n", |
185 | 185 | "You may have noticed the comment, `# noqa: F821`, in the method call above.\n", |
186 | 186 | "\n", |
187 | | - "This is a specially-formatted comment that tells my testing infrastructure to ignore (i.e. no quality assurance, or noqa, error for the type F821, which corresponds with a `NameError`).\n", |
| 187 | + "This is a specially-formatted comment that tells my testing infrastructure to ignore (i.e. no quality assurance, or `noqa`, error for the type F821, which corresponds with a `NameError`).\n", |
188 | 188 | "The reason we need to capture it is that the code testing tool doesn't understand the `%%sql` magic commands, and it can't find where `df01` was previously defined.\n", |
189 | 189 | "\n", |
190 | 190 | "For a project of this scope and update frequency, it helps to have some automated testing that helps me catch when things stop working.\n", |
191 | | - "One part of that is supressing errors that happen for some technical or intended reason, to isolate real problemsf." |
| 191 | + "One part of that is suppressing errors that happen for some technical or intended reason, to isolate real problems." |
192 | 192 | ] |
193 | 193 | }, |
194 | 194 | { |
|
265 | 265 | " , SUBSTRING(cusip, 1, 8) AS cusip8\n", |
266 | 266 | " , at, lt\n", |
267 | 267 | " FROM comp.funda\n", |
268 | | - " WHERE (datafmt = 'STD') AND \n", |
| 268 | + " WHERE (datafmt = 'STD') AND\n", |
269 | 269 | " (fyear BETWEEN 2000 AND 2020)\n", |
270 | 270 | " LIMIT 10\n" |
271 | 271 | ] |
|
315 | 315 | " , AVG(at) AS assets_avg\n", |
316 | 316 | " , SUM(ni) AS netincome_total\n", |
317 | 317 | " FROM comp.funda\n", |
318 | | - " WHERE (datafmt = 'STD') AND \n", |
| 318 | + " WHERE (datafmt = 'STD') AND\n", |
319 | 319 | " (fyear BETWEEN 2000 AND 2020)\n", |
320 | 320 | "GROUP BY gvkey\n", |
321 | 321 | " LIMIT 10\n" |
|
329 | 329 | "# Window functions\n", |
330 | 330 | "\n", |
331 | 331 | "Sometimes, we want data at the level of the table, but we would also like aggregated measures.\n", |
332 | | - "SQL has something called **window fuctions** which aggregate data like we did before, but then they **broadcast** it up to the level of the original table." |
| 332 | + "SQL has something called **window functions** which aggregate data like we did before, but then they **broadcast** it up to the level of the original table." |
333 | 333 | ] |
334 | 334 | }, |
335 | 335 | { |
|
350 | 350 | " , AVG(at) OVER(PARTITION BY gvkey) AS assets_avg\n", |
351 | 351 | " , SUM(ni) OVER(PARTITION BY gvkey) AS netincome_total\n", |
352 | 352 | " FROM comp.funda\n", |
353 | | - " WHERE (datafmt = 'STD') AND \n", |
| 353 | + " WHERE (datafmt = 'STD') AND\n", |
354 | 354 | " (fyear BETWEEN 2000 AND 2020)\n", |
355 | 355 | " LIMIT 10\n" |
356 | 356 | ] |
|
402 | 402 | " FROM comp.funda AS f\n", |
403 | 403 | " JOIN comp.company AS c\n", |
404 | 404 | " ON f.gvkey = c.gvkey\n", |
405 | | - " WHERE (f.datafmt = 'STD') AND \n", |
| 405 | + " WHERE (f.datafmt = 'STD') AND\n", |
406 | 406 | " (f.fyear BETWEEN 2000 AND 2020)\n", |
407 | 407 | " LIMIT 10\n" |
408 | 408 | ] |
|
470 | 470 | "name": "python", |
471 | 471 | "nbconvert_exporter": "python", |
472 | 472 | "pygments_lexer": "ipython3", |
473 | | - "version": "3.11.3" |
| 473 | + "version": "3.12.2" |
474 | 474 | }, |
475 | 475 | "vscode": { |
476 | 476 | "interpreter": { |
|
0 commit comments