Skip to content

Commit 2ce4ac6

Browse files
committed
fixed import errors
1 parent 4615841 commit 2ce4ac6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

30_plotly_intro_to_libraries.ipynb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@
268268
" Returns:\n",
269269
" pd.DataFrame: A DataFrame containing the happiness data.\n",
270270
" \"\"\"\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",
271275
" # Your code starts here\n",
272276
" return\n",
273277
" # Your code ends here"
@@ -345,13 +349,10 @@
345349
"metadata": {},
346350
"outputs": [],
347351
"source": [
348-
"\n",
352+
"import pandas as pd\n",
349353
"\n",
350354
"happyness = pd.read_csv('data/plotly_intro/World-happiness-report-updated_2024.csv', encoding='latin1')\n",
351355
"\n",
352-
"\n",
353-
"import pandas as pd\n",
354-
"\n",
355356
"# Assuming your dataframe is loaded into 'df'\n",
356357
"df = happyness\n",
357358
"print(\"--- First few rows of the dataframe ---\")\n",
@@ -459,7 +460,7 @@
459460
"plt.xlabel('Year')\n",
460461
"plt.ylabel('Frequency')\n",
461462
"plt.grid(True)\n",
462-
"plt.show()\n"
463+
"plt.show()"
463464
]
464465
},
465466
{
@@ -810,6 +811,7 @@
810811
"outputs": [],
811812
"source": [
812813
"from tutorial.intro_plotly_helper import full_clean_dataset, get_scatter_figure_with_years\n",
814+
"from plotly.offline import iplot\n",
813815
"\n",
814816
"dataset = full_clean_dataset()\n",
815817
"x_column = 'Freedom to make life choices'\n",
@@ -1201,7 +1203,7 @@
12011203
"Last but not least you can try to fix it yourself.\n",
12021204
"\n",
12031205
"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",
12051207
"\n",
12061208
"(If you are interested in a solution, we have a fixed version under tutorial.my_bubbly.py, feel free to check the differences.)\n"
12071209
]

tutorial/intro_plotly_helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import pandas as pd
3-
from bubbly.bubbly import bubbleplot
3+
4+
from tutorial.my_bubbly import bubbleplot
45

56

67
def get_happiness_data():
@@ -468,3 +469,4 @@ def frame_by_year(dataset, year, x_column, y_column, description_column):
468469
frame_by_year(dataset, year, x_column, y_column, description_column)
469470
for year in years
470471
]
472+
return figure

0 commit comments

Comments
 (0)