File tree Expand file tree Collapse file tree 4 files changed +22
-18
lines changed
Expand file tree Collapse file tree 4 files changed +22
-18
lines changed Original file line number Diff line number Diff line change 1- These files will allow you to work along with the [ Introducing DuckDB] ( https://realpython.com/introducing -duckdb/ ) tutorial.
1+ These files will allow you to work along with the [ Introducing DuckDB] ( https://realpython.com/python -duckdb/ ) tutorial.
22
33The files are:
44
5- Code Download .ipynb - Contains the code you see in the tutorial.
6- parties.json - JSON file containing political party information.
7- presidents.csv - CSV file containing president information.
8- presidents.parquet - Parquet file containing president information.
5+ - ` duckdb_code .ipynb` : Contains the code you see in the tutorial.
6+ - ` parties.json ` : JSON file containing political party information.
7+ - ` presidents.csv ` : CSV file containing president information.
8+ - ` presidents.parquet ` : Parquet file containing president information.
99
Original file line number Diff line number Diff line change 8888 "source" : [
8989 " **This code won't work.**\n " ,
9090 " \n " ,
91+ " ```python\n " ,
9192 " with duckdb.connect(database=\" presidents.db\" ) as conn:\n " ,
92- " conn.sql(\" SELECT * FROM presidents_relation\" )\n "
93+ " conn.sql(\" SELECT * FROM presidents_relation\" )\n " ,
94+ " ```"
9395 ]
9496 },
9597 {
343345 " print(\n " ,
344346 " conn.sql(\n " ,
345347 " \"\"\"\n " ,
346- " SELECT last_name, first_name\n " ,
347- " FROM presidents\n " ,
348- " WHERE sequence = 1\n " ,
349- " \"\"\"\n " ,
348+ " SELECT last_name, first_name\n " ,
349+ " FROM presidents\n " ,
350+ " WHERE sequence = 1\n " ,
351+ " \"\"\"\n " ,
350352 " )\n " ,
351353 " )"
352354 ]
391393 "source" : [
392394 " **Only run this code if you need to update your existing `short_name()` function**\n " ,
393395 " \n " ,
394- " duckdb.remove_function(\" short_name\" )"
396+ " ```python\n " ,
397+ " duckdb.remove_function(\" short_name\" )\n " ,
398+ " ```"
395399 ]
396400 },
397401 {
450454 " import duckdb\n " ,
451455 " \n " ,
452456 " with duckdb.connect(\" presidents.db\" ) as conn:\n " ,
453- " pandas_df = conn.sql(\n " ,
457+ " pandas_presidents = conn.sql(\n " ,
454458 " \"\"\"\n " ,
455459 " SELECT last_name, first_name\n " ,
456460 " FROM presidents\n " ,
457461 " WHERE sequence BETWEEN 2 AND 5\n " ,
458462 " \"\"\"\n " ,
459463 " ).df()\n " ,
460464 " \n " ,
461- " pandas_df "
465+ " pandas_presidents "
462466 ]
463467 },
464468 {
Original file line number Diff line number Diff line change 22# return a + b
33
44
5- def add_numbers (a : int | float , b : int | float ) -> int | float :
5+ def add_numbers (a : int | float , b : int | float ) -> float :
66 a , b = float (a ), float (b )
77 return a + b
88
Original file line number Diff line number Diff line change 11# import pytest
22
33# def greet(name):
4- # print(f"Hello, {name}")
4+ # print(f"Hello, {name}! ")
55
66
77# def test_greet(capsys):
88# greet("Alice")
99# captured = capsys.readouterr()
10- # assert captured.out.strip() == "Hello, Alice"
10+ # assert captured.out.strip() == "Hello, Alice! "
1111
1212
1313def greet (name : str ) -> str :
14- return f"Hello, { name } "
14+ return f"Hello, { name } ! "
1515
1616
1717# Easy to test
1818def test_greet ():
19- assert greet ("Alice" ) == "Hello, Alice"
19+ assert greet ("Alice" ) == "Hello, Alice! "
You can’t perform that action at this time.
0 commit comments