|
174 | 174 | این را با `pl.read_csv` میخوانیم |
175 | 175 |
|
176 | 176 | ```{code-cell} ipython3 |
177 | | -url = ('https://raw.githubusercontent.com/QuantEcon/' |
178 | | - 'lecture-python-programming/main/lectures/_static/' |
179 | | - 'lecture_specific/pandas/data/test_pwt.csv') |
| 177 | +url = 'https://github.com/QuantEcon/data-lectures/raw/main/lectures/test_pwt.csv' |
180 | 178 | df = pl.read_csv(url) |
181 | 179 | df |
182 | 180 | ``` |
@@ -360,9 +358,7 @@ plt.show() |
360 | 358 |
|
361 | 359 | ```{code-cell} ipython3 |
362 | 360 | # Reload the dataset |
363 | | -url = ('https://raw.githubusercontent.com/QuantEcon/' |
364 | | - 'lecture-python-programming/main/lectures/_static/' |
365 | | - 'lecture_specific/pandas/data/test_pwt.csv') |
| 361 | +url = 'https://github.com/QuantEcon/data-lectures/raw/main/lectures/test_pwt.csv' |
366 | 362 | df_full = pl.read_csv(url) |
367 | 363 | ``` |
368 | 364 |
|
@@ -438,9 +434,7 @@ import pandas as pd |
438 | 434 | import time |
439 | 435 |
|
440 | 436 | # Small dataset -- Penn World Tables (~8 rows) |
441 | | -url = ('https://raw.githubusercontent.com/QuantEcon/' |
442 | | - 'lecture-python-programming/main/lectures/_static/' |
443 | | - 'lecture_specific/pandas/data/test_pwt.csv') |
| 437 | +url = 'https://github.com/QuantEcon/data-lectures/raw/main/lectures/test_pwt.csv' |
444 | 438 | small_pd = pd.read_csv(url) |
445 | 439 | small_pl = pl.read_csv(url) |
446 | 440 | ``` |
@@ -480,13 +474,13 @@ print(f"Small data -- pandas: {pd_small:.4f}s | Polars eager: {pl_small:.4f}s" |
480 | 474 |
|
481 | 475 | ```{code-cell} ipython3 |
482 | 476 | n = 5_000_000 |
483 | | -np.random.seed(42) |
| 477 | +rng = np.random.default_rng(42) |
484 | 478 |
|
485 | | -groups = np.random.choice(['A', 'B', 'C', 'D'], n) |
486 | | -values = np.random.randn(n) |
487 | | -weights = np.random.rand(n) |
488 | | -extra1 = np.random.randn(n) |
489 | | -extra2 = np.random.randn(n) |
| 479 | +groups = rng.choice(['A', 'B', 'C', 'D'], n) |
| 480 | +values = rng.standard_normal(n) |
| 481 | +weights = rng.random(n) |
| 482 | +extra1 = rng.standard_normal(n) |
| 483 | +extra2 = rng.standard_normal(n) |
490 | 484 |
|
491 | 485 | big_pd = pd.DataFrame({ |
492 | 486 | 'group': groups, 'value': values, |
@@ -821,4 +815,4 @@ plt.show() |
821 | 815 | ``` |
822 | 816 |
|
823 | 817 | ```{solution-end} |
824 | | -``` |
| 818 | +``` |
0 commit comments