\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","variable_name":"hier_df1","summary":"{\n \"name\": \"hier_df1\",\n \"rows\": 3,\n \"fields\": [\n {\n \"column\": [\n \"Kyoto\",\n \"Yellow\"\n ],\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 4,\n \"min\": 0,\n \"max\": 8,\n \"num_unique_values\": 3,\n \"samples\": [\n 0,\n 4,\n 8\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": [\n \"Nagoya\",\n \"Yellow\"\n ],\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 4,\n \"min\": 1,\n \"max\": 9,\n \"num_unique_values\": 3,\n \"samples\": [\n 1,\n 5,\n 9\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": [\n \"Hokkaido\",\n \"Red\"\n ],\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 4,\n \"min\": 2,\n \"max\": 10,\n \"num_unique_values\": 3,\n \"samples\": [\n 2,\n 6,\n 10\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": [\n \"Kyoto\",\n \"Blue\"\n ],\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 4,\n \"min\": 3,\n \"max\": 11,\n \"num_unique_values\": 3,\n \"samples\": [\n 3,\n 7,\n 11\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":73}],"source":["hier_df1 = DataFrame(\n"," np.arange(12).reshape((3,4)),\n"," index = [['c','d','d'], [1,2,1]],\n"," columns = [\n"," ['Kyoto','Nagoya','Hokkaido','Kyoto'],\n"," ['Yellow','Yellow','Red','Blue']\n"," ]\n",")\n","\n","hier_df1.index.names = ['key1','key2']\n","hier_df1.columns.names = ['city','color']\n","hier_df1"]},{"cell_type":"markdown","metadata":{"id":"t0owRdFQh1ch"},"source":["#### \n","\n","Let's examine the relationship between `Score` and `Members` in the `anime_data_extracted` dataset.\n","\n","(1) Group `Scores` into fixed rating ranges and save the result as `score_tiers`:\n","1. 0.0~6.0: 'Low'\n","2. 6.0~7.5: 'Average'\n","3. 7.5~8.5: 'High'\n","4. 8.5~10.0: 'Very High'"]},{"cell_type":"code","execution_count":74,"metadata":{"id":"LL0Ubi7Ih1ch","executionInfo":{"status":"ok","timestamp":1790160552129,"user_tz":-540,"elapsed":46,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}}},"outputs":[],"source":["# Convert the Score column to type float first\n","anime_data_extracted[\"Score\"] = anime_data_extracted[\"Score\"].astype(float)\n","\n","scores = [0.0,6.0,7.5,8.5,10.0]\n","score_tier_names = ['Low','Average','High','Very High']\n","score_tiers = pd.cut(anime_data_extracted[\"Score\"], scores, labels=score_tier_names)"]},{"cell_type":"markdown","source":["(2) Divide the member counts into 4 equal-sized popularity groups and save the result as `popularity_tiers`. Use the names 'Niche', 'Moderate', 'Popular', and 'Viral Hit' from lowest to highers."],"metadata":{"id":"que8FkzMw8Hb"}},{"cell_type":"code","source":["popularity_tier_names = ['Niche','Moderate','Popular','Viral Hit']\n","popularity_tiers = pd.qcut(anime_data_extracted['Members'],4,labels=popularity_tier_names)"],"metadata":{"id":"6e1EvLjjw-HH","executionInfo":{"status":"ok","timestamp":1790160552133,"user_tz":-540,"elapsed":2,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}}},"execution_count":75,"outputs":[]},{"cell_type":"markdown","source":["Run this code to display a 4 by 4 frequency grid showing how many anime fall into each score and popularity combination."],"metadata":{"id":"fyqrTI8wxoN8"}},{"cell_type":"code","source":["# Turns row categories into a full 2D table\n","pd.DataFrame({\"Score\": score_tiers, \"Members\": popularity_tiers}).value_counts().unstack()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":206},"id":"crzSkv2vxq5p","executionInfo":{"status":"ok","timestamp":1790160552195,"user_tz":-540,"elapsed":60,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}},"outputId":"16ad21d9-7576-45b7-d8ce-4f67698e9945"},"execution_count":76,"outputs":[{"output_type":"execute_result","data":{"text/plain":["Members Niche Moderate Popular Viral Hit\n","Score \n","Low 2000.0 941.0 352.0 100.0\n","Average 1108.0 2131.0 2446.0 1770.0\n","High 2.0 29.0 305.0 1134.0\n","Very High NaN NaN 2.0 101.0"],"text/html":["\n","
\n","
\n","\n","
\n"," \n","
\n","
Members
\n","
Niche
\n","
Moderate
\n","
Popular
\n","
Viral Hit
\n","
\n","
\n","
Score
\n","
\n","
\n","
\n","
\n","
\n"," \n"," \n","
\n","
Low
\n","
2000.0
\n","
941.0
\n","
352.0
\n","
100.0
\n","
\n","
\n","
Average
\n","
1108.0
\n","
2131.0
\n","
2446.0
\n","
1770.0
\n","
\n","
\n","
High
\n","
2.0
\n","
29.0
\n","
305.0
\n","
1134.0
\n","
\n","
\n","
Very High
\n","
NaN
\n","
NaN
\n","
2.0
\n","
101.0
\n","
\n"," \n","
\n","
\n","
\n","\n","
\n"," \n","\n"," \n","\n"," \n","
\n","\n","
\n","
\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","summary":"{\n \"name\": \"pd\",\n \"rows\": 4,\n \"fields\": [\n {\n \"column\": \"Score\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"Average\",\n \"Very High\",\n \"Low\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Niche\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1000.9082542038173,\n \"min\": 2.0,\n \"max\": 2000.0,\n \"num_unique_values\": 3,\n \"samples\": [\n 2000.0,\n 1108.0,\n 2.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Moderate\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1054.0594543636205,\n \"min\": 29.0,\n \"max\": 2131.0,\n \"num_unique_values\": 3,\n \"samples\": [\n 941.0,\n 2131.0,\n 29.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Popular\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1123.9206303531105,\n \"min\": 2.0,\n \"max\": 2446.0,\n \"num_unique_values\": 4,\n \"samples\": [\n 2446.0,\n 2.0,\n 352.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Viral Hit\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 822.3544957417492,\n \"min\": 100.0,\n \"max\": 1770.0,\n \"num_unique_values\": 4,\n \"samples\": [\n 1770.0,\n 101.0,\n 100.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":76}]},{"cell_type":"markdown","metadata":{"id":"BvKWf-oxh1cj"},"source":["#### \n","\n","Anime fans often joke that shows adapted from \"Light Novels\" have ridiculously long titles compared to original shows or manga. Let's see if this is true with `anime_data_extracted`. Group the dataset by `Source` and calculate the average (mean) `Title_Length` for each source type. Sort the results in descending order to see which source has the largest names."]},{"cell_type":"code","execution_count":77,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":617},"executionInfo":{"elapsed":33,"status":"ok","timestamp":1790160552195,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"},"user_tz":-540},"id":"zj06plASh1cj","outputId":"96e52681-120a-4d19-981e-0cfff3b17747"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["Source\n","4-koma manga 25.959839\n","Book 23.294118\n","Card game 28.116667\n","Digital manga 34.076923\n","Game 29.982069\n","Light novel 32.557123\n","Manga 25.845590\n","Music 17.157635\n","Novel 24.204489\n","Original 23.118391\n","Other 24.910543\n","Picture book 19.941176\n","Radio 34.166667\n","Unknown 27.155207\n","Visual novel 26.676230\n","Web manga 24.973684\n","Name: Title_Length, dtype: float64"],"text/html":["
\n","\n","
\n"," \n","
\n","
\n","
Title_Length
\n","
\n","
\n","
Source
\n","
\n","
\n"," \n"," \n","
\n","
4-koma manga
\n","
25.959839
\n","
\n","
\n","
Book
\n","
23.294118
\n","
\n","
\n","
Card game
\n","
28.116667
\n","
\n","
\n","
Digital manga
\n","
34.076923
\n","
\n","
\n","
Game
\n","
29.982069
\n","
\n","
\n","
Light novel
\n","
32.557123
\n","
\n","
\n","
Manga
\n","
25.845590
\n","
\n","
\n","
Music
\n","
17.157635
\n","
\n","
\n","
Novel
\n","
24.204489
\n","
\n","
\n","
Original
\n","
23.118391
\n","
\n","
\n","
Other
\n","
24.910543
\n","
\n","
\n","
Picture book
\n","
19.941176
\n","
\n","
\n","
Radio
\n","
34.166667
\n","
\n","
\n","
Unknown
\n","
27.155207
\n","
\n","
\n","
Visual novel
\n","
26.676230
\n","
\n","
\n","
Web manga
\n","
24.973684
\n","
\n"," \n","
\n","
"]},"metadata":{},"execution_count":77}],"source":["# Creates a new column named 'Title_Length' that will store the length of each anime\n","anime_data_extracted['Title_Length'] = anime_data_extracted['Name'].str.len()\n","\n","anime_data_extracted.groupby('Source')['Title_Length'].mean()"]},{"cell_type":"markdown","metadata":{"id":"YyBz0o72h1cj"},"source":["#### \n","\n","Let's investigate the different animation studios. Group the `anime_data_extracted` dataset by `Studios`, then use the `agg()` function on the `Score` column to find the `mean`, `max`, and `count` for each studio."]},{"cell_type":"code","execution_count":78,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":455},"executionInfo":{"elapsed":33,"status":"ok","timestamp":1790160552224,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"},"user_tz":-540},"id":"2SsezzPyh1cj","outputId":"eb79295e-7f41-44b8-fa36-b040d43c7124"},"outputs":[{"output_type":"execute_result","data":{"text/plain":[" mean max count\n","Studios \n","10Gauge 6.490000 6.53 2\n","10Gauge, Studio DURIAN 7.520000 7.52 1\n","2:10 AM Animation 7.023333 7.25 3\n","8bit 7.072683 8.07 41\n","A-1 Pictures 7.138703 8.74 185\n","... ... ... ...\n","monofilmo 7.335000 7.40 2\n","pH Studio 6.260000 6.26 1\n","production doA 7.336667 7.79 3\n","ufotable 7.248852 8.79 61\n","ufotable, feel., Studio Flag 6.910000 6.91 1\n","\n","[948 rows x 3 columns]"],"text/html":["\n","
\n","
\n","\n","
\n"," \n","
\n","
\n","
mean
\n","
max
\n","
count
\n","
\n","
\n","
Studios
\n","
\n","
\n","
\n","
\n"," \n"," \n","
\n","
10Gauge
\n","
6.490000
\n","
6.53
\n","
2
\n","
\n","
\n","
10Gauge, Studio DURIAN
\n","
7.520000
\n","
7.52
\n","
1
\n","
\n","
\n","
2:10 AM Animation
\n","
7.023333
\n","
7.25
\n","
3
\n","
\n","
\n","
8bit
\n","
7.072683
\n","
8.07
\n","
41
\n","
\n","
\n","
A-1 Pictures
\n","
7.138703
\n","
8.74
\n","
185
\n","
\n","
\n","
...
\n","
...
\n","
...
\n","
...
\n","
\n","
\n","
monofilmo
\n","
7.335000
\n","
7.40
\n","
2
\n","
\n","
\n","
pH Studio
\n","
6.260000
\n","
6.26
\n","
1
\n","
\n","
\n","
production doA
\n","
7.336667
\n","
7.79
\n","
3
\n","
\n","
\n","
ufotable
\n","
7.248852
\n","
8.79
\n","
61
\n","
\n","
\n","
ufotable, feel., Studio Flag
\n","
6.910000
\n","
6.91
\n","
1
\n","
\n"," \n","
\n","
948 rows × 3 columns
\n","
\n","
\n","\n","
\n"," \n","\n"," \n","\n"," \n","
\n","\n","
\n","
\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","summary":"{\n \"name\": \"anime_data_extracted\",\n \"rows\": 948,\n \"fields\": [\n {\n \"column\": \"Studios\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 948,\n \"samples\": [\n \"RAMS\",\n \"drop\",\n \"Bridge, Husio Studio\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"mean\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.7388706363199753,\n \"min\": 2.18,\n \"max\": 8.61,\n \"num_unique_values\": 621,\n \"samples\": [\n 6.845,\n 6.7884,\n 5.05\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"max\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.9573712794339168,\n \"min\": 2.18,\n \"max\": 9.19,\n \"num_unique_values\": 352,\n \"samples\": [\n 5.75,\n 8.61,\n 6.03\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"count\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 119,\n \"min\": 1,\n \"max\": 3511,\n \"num_unique_values\": 75,\n \"samples\": [\n 185,\n 442,\n 18\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":78}],"source":["anime_data_extracted.groupby('Studios')['Score'].agg(['mean','max','count'])"]},{"cell_type":"markdown","metadata":{"id":"ITHTpMFFh1ck"},"source":["#### \n","\n","We discussed many methods of handling missing data. Now let's observe how the choice of which method to use affects our analysis of the data. We are going to test these three methods on the `Score` column and see how it affects the mean value of `Score`.\n","\n","1. Drop all rows with missing data\n","2. Fill all missing `Score` data with -1\n","3. Fill all missing `Score` data with the mean value of the `Score` data we have\n","\n","Run this cell to turn all of the values in `Score` into `float` so we can calculate the mean.\n"]},{"cell_type":"code","source":["anime_data = anime_data.replace('Unknown', np.nan)\n","cols_to_use2 = [\n"," \"Name\", \"Score\", \"Type\", \"Premiered\", \"Studios\", \"Source\",\n","]\n","anime_data_extracted_pracq = anime_data[cols_to_use2]\n","anime_data_extracted_pracq[\"Score\"] = anime_data_extracted_pracq[\"Score\"].astype(float)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"aSjMCf492Ypf","executionInfo":{"status":"ok","timestamp":1790160552283,"user_tz":-540,"elapsed":32,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}},"outputId":"de1018fd-63b5-47a6-9333-4b0e95f73872"},"execution_count":79,"outputs":[{"output_type":"stream","name":"stderr","text":["/tmp/ipykernel_3197/2207846101.py:6: SettingWithCopyWarning: \n","A value is trying to be set on a copy of a slice from a DataFrame.\n","Try using .loc[row_indexer,col_indexer] = value instead\n","\n","See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n"," anime_data_extracted_pracq[\"Score\"] = anime_data_extracted_pracq[\"Score\"].astype(float)\n"]}]},{"cell_type":"markdown","source":["(1) Calculate the mean `Score` after removing all rows with at least one missing value."],"metadata":{"id":"kk9bf-z22wQt"}},{"cell_type":"code","source":["anime_data_extracted_dropna = anime_data_extracted_pracq.dropna()\n","anime_data_extracted_dropna[\"Score\"].mean()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Ym31yuYJ2y3R","executionInfo":{"status":"ok","timestamp":1790160552297,"user_tz":-540,"elapsed":12,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}},"outputId":"5ef3f5d9-b459-43be-896a-1dfa5c304d3d"},"execution_count":80,"outputs":[{"output_type":"execute_result","data":{"text/plain":["np.float64(6.97429798578199)"]},"metadata":{},"execution_count":80}]},{"cell_type":"markdown","source":["(2) Calculate the mean `Score` after filling all missing values with -1."],"metadata":{"id":"_qZJbP2G20Gh"}},{"cell_type":"code","source":["anime_data_extracted_filln1 = anime_data_extracted_pracq.fillna(-1)\n","anime_data_extracted_filln1[\"Score\"].mean()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"KJc90cqJ23gg","executionInfo":{"status":"ok","timestamp":1790160552331,"user_tz":-540,"elapsed":8,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}},"outputId":"33c421aa-219f-49a8-9fc6-bf0fe4bcc216"},"execution_count":81,"outputs":[{"output_type":"execute_result","data":{"text/plain":["np.float64(4.311564742056714)"]},"metadata":{},"execution_count":81}]},{"cell_type":"markdown","source":["(3) Calculate the mean `Score` after filling all missing `Score` values with the mean `Score` value for the data we currently have."],"metadata":{"id":"nOgFI_rQ25vq"}},{"cell_type":"code","source":["anime_data_extracted_fillmean = anime_data_extracted_pracq.fillna(anime_data_extracted_pracq[\"Score\"].mean())\n","anime_data_extracted_fillmean[\"Score\"].mean()"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"LuuSjgYC28nw","executionInfo":{"status":"ok","timestamp":1790160552343,"user_tz":-540,"elapsed":11,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}},"outputId":"0a6e4919-e45b-47c6-9167-37a1e6ba2538"},"execution_count":82,"outputs":[{"output_type":"execute_result","data":{"text/plain":["np.float64(6.509999194911843)"]},"metadata":{},"execution_count":82}]},{"cell_type":"markdown","source":["As we can see, the method we choose to handle the missing values greatly affects the mean `Score` value. There is never an absolute correct method to choose, and it is your job as a data scientist to balance the trade offs from both the data science side and the domain side and to choose the method that makes the most sense."],"metadata":{"id":"TKqP_5k43EJp"}},{"cell_type":"markdown","metadata":{"id":"E8ZHfZo7h1co"},"source":["## 3.7 Comprehensive Question"]},{"cell_type":"markdown","metadata":{"id":"2Ym3VDDah1co"},"source":["### Comprehensive Question 3-1 Data Manipulation\n","\n","Using the data `student-mat.csv', which is the data showing math scores, answer the following questions.\n","\n","(1) For the above data, calculate the average score of `G1` by age (`age`) x sex (`sex`) and create a table (table) such that the vertical axis is age (`age`) and the horizontal axis is sex (`sex`).\n","\n","(2) For the result table displayed in (1), delete all the rows (records) that are NaN."]},{"cell_type":"code","source":["# Specify the url with data\n","url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/00320/student.zip'\n","\n","# Acquire data from the url\n","r = requests.get(url, stream=True)\n","\n","# read and extract the zipfile\n","z = zipfile.ZipFile(io.BytesIO(r.content))\n","z.extractall()\n","\n","# Load the data\n","student_data_math = pd.read_csv('student-mat.csv', sep=';')"],"metadata":{"id":"F6pXU3334Xf0","executionInfo":{"status":"ok","timestamp":1790160552544,"user_tz":-540,"elapsed":202,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}}},"execution_count":83,"outputs":[]},{"cell_type":"code","execution_count":84,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":332},"executionInfo":{"elapsed":25,"status":"ok","timestamp":1790160552548,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"},"user_tz":-540},"id":"jGCjGRfGh1cp","outputId":"d82c9e72-99f4-4274-e4af-62b2d54eb843"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["sex F M\n","age \n","15 10.052632 12.250000\n","16 10.203704 11.740000\n","17 11.103448 10.600000\n","18 10.883721 10.538462\n","19 10.642857 9.700000\n","20 15.000000 13.000000\n","21 NaN 10.000000\n","22 NaN 6.000000"],"text/html":["\n","
\n"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"dataframe","summary":"{\n \"name\": \"student_data_math\",\n \"rows\": 6,\n \"fields\": [\n {\n \"column\": \"age\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 15,\n \"max\": 20,\n \"num_unique_values\": 6,\n \"samples\": [\n 15,\n 16,\n 20\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"F\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1.8488000470985881,\n \"min\": 10.052631578947368,\n \"max\": 15.0,\n \"num_unique_values\": 6,\n \"samples\": [\n 10.052631578947368,\n 10.203703703703704,\n 15.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"M\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1.2341722585231316,\n \"min\": 9.7,\n \"max\": 13.0,\n \"num_unique_values\": 6,\n \"samples\": [\n 12.25,\n 11.74,\n 13.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"}},"metadata":{},"execution_count":85}],"source":["# Answer\n","# (2)\n","student_data_math.groupby(['age','sex'])['G1'].mean().unstack().dropna()"]},{"cell_type":"markdown","metadata":{"id":"mA5_GWsWh1cp"},"source":["# How to Load Data"]},{"cell_type":"code","execution_count":86,"metadata":{"id":"sRQ2l5Tph1cp","executionInfo":{"status":"ok","timestamp":1790160553131,"user_tz":-540,"elapsed":552,"user":{"displayName":"木村進太郎","userId":"02485141327510571181"}}},"outputs":[],"source":["# Specify url with data\n","url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/00320/student.zip'\n","# Specify data from url\n","r = requests.get(url, stream=True)\n","# Extract student-mat.csv in the zipfile to the data directory in the current directory\n","with zipfile.ZipFile(io.BytesIO(r.content)) as existing_zip:\n"," existing_zip.extract('student-mat.csv', 'data')\n","# Directory where csvfile exists\n","data_dir = './data'\n","path = os.path.join(data_dir, 'student-mat.csv')\n","student_data_math = pd.read_csv(path,sep=';')"]},{"cell_type":"markdown","metadata":{"id":"Y4cxMUX5FF7F"},"source":["\n","\n","---\n","\n"]},{"cell_type":"markdown","metadata":{"id":"ig8CJYW2G7NY"},"source":["**Acknowledgement**: For the usage of dataset below\n","https://archive.ics.uci.edu/ml/machine-learning-databases/00320/student.zip\n","\n","**References**: Dua, D. and Graff, C. (2019). UCI Machine Learning Repository [[http://archive.ics.uci.edu/ml](http://archive.ics.uci.edu/ml)]. Irvine, CA: University of California, School of Information and Computer Science.\n","\n","P. Cortez and A. Silva. Using Data Mining to Predict Secondary School Student Performance. In A. Brito and J. Teixeira Eds., Proceedings of 5th FUture BUsiness TEChnology Conference (FUBUTEC 2008) pp.5-12, Porto, Portugal, April, 2008, EUROSIS, ISBN 978-9077381-39-7.\n","[http://www3.dsi.uminho.pt/pcortez/student.pdf](http://www3.dsi.uminho.pt/pcortez/student.pdf)"]}],"metadata":{"anaconda-cloud":{},"colab":{"provenance":[{"file_id":"1gM7svL2n3J7iMAWvPqw3brnjeqhQfHw-","timestamp":1625840295433}],"toc_visible":true},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.6"}},"nbformat":4,"nbformat_minor":0}