Skip to content

Commit db5b9b8

Browse files
authored
Merge branch 'master' into python-control-flow
2 parents e51157a + a7f6e16 commit db5b9b8

20 files changed

+172
-956
lines changed

polars-groupby/README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
This download contains materials for the Real Python tutorial [How to Group Data Using Polars .group_by()](https://realpython.com/aggregating-and-grouping-data-in-polars-groupby/).
1+
# How to Group Data Using Polars `.group_by()`
22

3-
You should create a new folder named aggregations on your computer and place each of these files inside it. You may also consider creating a [Python virtual environment](https://realpython.com/python-virtual-environments-a-primer/) within this folder.
3+
This download contains materials for the Real Python tutorial [How to Group Data Using Polars `.group_by()`](https://realpython.com/polars-groupby/).
44

5-
Your download bundle contains the following files:
5+
## Installation
6+
7+
Create a [Python virtual environment](https://realpython.com/python-virtual-environments-a-primer/), activate it, and install Polars along with its dependencies into it:
8+
9+
```sh
10+
$ python -m venv venv/
11+
$ source venv/bin/activate
12+
(venv) $ python -m pip install polars
13+
```
614

7-
course.parquet - This file contains all data from both `math.parquet` and `portuguese.parquet`.
8-
math.parquet - This file contains data relating to a mathematics class.
9-
portuguese.parquet - This file contains data relating to a Portuguese language class.
10-
student.txt - This file defines every field in the three files above.
11-
math_classes.parquet - This file contains data used in the time series analysis examples.
15+
## Contents
16+
17+
Your download bundle contains the following files:
1218

13-
tutorial_code.ipynb - This file contains the code used in the tutorial.
14-
solutions.ipynb - This file contains the solutions to the exercises.
19+
| Filename | Description |
20+
|------------------------ |------------------------------------------------------------ |
21+
| `course.parquet` | All data from both `math.parquet` and `portuguese.parquet` |
22+
| `math.parquet` | Data relating to a mathematics class |
23+
| `portuguese.parquet` | Data relating to a Portuguese language class |
24+
| `student.txt` | Defines every field in the three files above |
25+
| `math_classes.parquet` | Data used in the time series analysis examples |
26+
| `tutorial_code.ipynb` | The code used in the tutorial |
27+
| `solutions.ipynb` | The solutions to the exercises |

polars-groupby/post_tr2.md

Lines changed: 0 additions & 946 deletions
This file was deleted.

python-nested-loops/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Nested Loops in Python
2+
3+
This folder provides the code examples for the Real Python tutorial [Nested Loops in Python](https://realpython.com/nested-loops-python/).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for hour in range(0, 24):
2+
for minute in range(0, 60):
3+
print(f"{hour:02d}:{minute:02d}")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
crew_ids = [1, 2, 8, 4, 5, 6, 7, 8, 9, 10]
2+
for i, first_id in enumerate(crew_ids):
3+
for second_id in crew_ids[i + 1 :]:
4+
if first_id == second_id:
5+
print(f"Clone found: id={first_id} is a duplicate.")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
crew_ids = [1, 2, 8, 4, 5, 6, 7, 8, 9, 10]
2+
detected = set()
3+
for crew_id in crew_ids:
4+
if crew_id in detected:
5+
print(f"Clone found: id={crew_id} is a duplicate.")
6+
else:
7+
detected.add(crew_id)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from collections import Counter
2+
3+
crew_ids = [1, 2, 8, 4, 5, 6, 7, 8, 9, 10]
4+
detected = Counter(crew_ids)
5+
for key, value in detected.items():
6+
if value > 1:
7+
print(f"Clone found: id={key} is a duplicate.")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource_donators = [[8, 6, 3], [9, 2, 7], [4, 1, 5]]
2+
total_resources = 0
3+
for planet in resource_donators:
4+
for resource in planet:
5+
total_resources += resource
6+
7+
print(f"All resources gathered for interstellar travels: {total_resources}")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
for multiplicant in range(1, 11):
2+
for multiplier in range(1, 4):
3+
expression = f"{multiplicant:>2d} × {multiplier}"
4+
product = multiplicant * multiplier
5+
print(f"{expression} = {product:>2d}", end="\t")
6+
print()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
while True:
2+
word = input("Enter a word (or type 'exit' to stop): ")
3+
4+
if word == "exit":
5+
break
6+
7+
for letter in word:
8+
print(letter)

0 commit comments

Comments
 (0)