|
268 | 268 | " Returns:\n", |
269 | 269 | " pd.DataFrame: A DataFrame containing the happiness data.\n", |
270 | 270 | " \"\"\"\n", |
| 271 | + " # Read in the data\n", |
| 272 | + " happiness_df = pd.read_csv(path_to_happiness, encoding=\"latin1\")\n", |
| 273 | + "\n", |
| 274 | + " return happiness_df\n", |
271 | 275 | " # Your code starts here\n", |
272 | 276 | " return\n", |
273 | 277 | " # Your code ends here" |
|
345 | 349 | "metadata": {}, |
346 | 350 | "outputs": [], |
347 | 351 | "source": [ |
348 | | - "\n", |
| 352 | + "import pandas as pd\n", |
349 | 353 | "\n", |
350 | 354 | "happyness = pd.read_csv('data/plotly_intro/World-happiness-report-updated_2024.csv', encoding='latin1')\n", |
351 | 355 | "\n", |
352 | | - "\n", |
353 | | - "import pandas as pd\n", |
354 | | - "\n", |
355 | 356 | "# Assuming your dataframe is loaded into 'df'\n", |
356 | 357 | "df = happyness\n", |
357 | 358 | "print(\"--- First few rows of the dataframe ---\")\n", |
|
459 | 460 | "plt.xlabel('Year')\n", |
460 | 461 | "plt.ylabel('Frequency')\n", |
461 | 462 | "plt.grid(True)\n", |
462 | | - "plt.show()\n" |
| 463 | + "plt.show()" |
463 | 464 | ] |
464 | 465 | }, |
465 | 466 | { |
|
810 | 811 | "outputs": [], |
811 | 812 | "source": [ |
812 | 813 | "from tutorial.intro_plotly_helper import full_clean_dataset, get_scatter_figure_with_years\n", |
| 814 | + "from plotly.offline import iplot\n", |
813 | 815 | "\n", |
814 | 816 | "dataset = full_clean_dataset()\n", |
815 | 817 | "x_column = 'Freedom to make life choices'\n", |
|
1201 | 1203 | "Last but not least you can try to fix it yourself.\n", |
1202 | 1204 | "\n", |
1203 | 1205 | "So as an exercise we exported the bubbly library as a file bubbly.py into the folder data.plotly_intro. It is quite a short library so quite managable.\n", |
1204 | | - "Try to figure out what the error is exactly and then fix the library locally until the same code below compiles.\n", |
| 1206 | + "Try to figure out what the error is exactly and then fix the library locally by modifying only the file `data/plotly_intro/bubbly.py` until the same code below compiles.\n", |
1205 | 1207 | "\n", |
1206 | 1208 | "(If you are interested in a solution, we have a fixed version under tutorial.my_bubbly.py, feel free to check the differences.)\n" |
1207 | 1209 | ] |
|
0 commit comments