diff --git a/your-code/main.ipynb b/your-code/main.ipynb index e196ddb..884e445 100755 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -11,11 +11,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 95, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "import pandas as pd\n", + "import numpy as np" ] }, { @@ -27,11 +29,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 96, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "path = ('apple_store.csv')" ] }, { @@ -45,11 +48,231 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 97, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idtrack_namesize_bytespricerating_count_totrating_count_veruser_ratinguser_rating_verprime_genre
0281656475PAC-MAN Premium1007882243.9921292264.04.5Games
1281796108Evernote - stay organized1585786880.00161065264.03.5Productivity
2281940292WeatherBug - Local Weather, Radar, Maps, Alerts1005240320.0018858328223.54.5Weather
3282614216eBay: Best App to Buy, Sell, Save! Online Shop...1285120000.002622416494.04.5Shopping
4282935706Bible927744000.0098592053204.55.0Reference
..............................
71921187617475Kubik1266442240.00142754.54.5Games
71931187682390VR Roller-Coaster1207603200.0030304.54.5Games
71941187779532Bret Michaels Emojis + Lyric Keyboard1113221121.991504.50.0Utilities
71951187838770VR Roller Coaster World - Virtual Reality972359680.0085324.54.5Games
71961188375727Escape the Sweet Shop Series908984320.00335.05.0Games
\n", + "

7197 rows × 9 columns

\n", + "
" + ], + "text/plain": [ + " id track_name \\\n", + "0 281656475 PAC-MAN Premium \n", + "1 281796108 Evernote - stay organized \n", + "2 281940292 WeatherBug - Local Weather, Radar, Maps, Alerts \n", + "3 282614216 eBay: Best App to Buy, Sell, Save! Online Shop... \n", + "4 282935706 Bible \n", + "... ... ... \n", + "7192 1187617475 Kubik \n", + "7193 1187682390 VR Roller-Coaster \n", + "7194 1187779532 Bret Michaels Emojis + Lyric Keyboard \n", + "7195 1187838770 VR Roller Coaster World - Virtual Reality \n", + "7196 1188375727 Escape the Sweet Shop Series \n", + "\n", + " size_bytes price rating_count_tot rating_count_ver user_rating \\\n", + "0 100788224 3.99 21292 26 4.0 \n", + "1 158578688 0.00 161065 26 4.0 \n", + "2 100524032 0.00 188583 2822 3.5 \n", + "3 128512000 0.00 262241 649 4.0 \n", + "4 92774400 0.00 985920 5320 4.5 \n", + "... ... ... ... ... ... \n", + "7192 126644224 0.00 142 75 4.5 \n", + "7193 120760320 0.00 30 30 4.5 \n", + "7194 111322112 1.99 15 0 4.5 \n", + "7195 97235968 0.00 85 32 4.5 \n", + "7196 90898432 0.00 3 3 5.0 \n", + "\n", + " user_rating_ver prime_genre \n", + "0 4.5 Games \n", + "1 3.5 Productivity \n", + "2 4.5 Weather \n", + "3 4.5 Shopping \n", + "4 5.0 Reference \n", + "... ... ... \n", + "7192 4.5 Games \n", + "7193 4.5 Games \n", + "7194 0.0 Utilities \n", + "7195 4.5 Games \n", + "7196 5.0 Games \n", + "\n", + "[7197 rows x 9 columns]" + ] + }, + "execution_count": 97, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "data = pd.read_csv(\"apple_store.csv\")\n", + "data" ] }, { @@ -63,11 +286,137 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 98, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idtrack_namesize_bytespricerating_count_totrating_count_veruser_ratinguser_rating_verprime_genre
0281656475PAC-MAN Premium1007882243.9921292264.04.5Games
1281796108Evernote - stay organized1585786880.00161065264.03.5Productivity
2281940292WeatherBug - Local Weather, Radar, Maps, Alerts1005240320.0018858328223.54.5Weather
3282614216eBay: Best App to Buy, Sell, Save! Online Shop...1285120000.002622416494.04.5Shopping
4282935706Bible927744000.0098592053204.55.0Reference
\n", + "
" + ], + "text/plain": [ + " id track_name size_bytes \\\n", + "0 281656475 PAC-MAN Premium 100788224 \n", + "1 281796108 Evernote - stay organized 158578688 \n", + "2 281940292 WeatherBug - Local Weather, Radar, Maps, Alerts 100524032 \n", + "3 282614216 eBay: Best App to Buy, Sell, Save! Online Shop... 128512000 \n", + "4 282935706 Bible 92774400 \n", + "\n", + " price rating_count_tot rating_count_ver user_rating user_rating_ver \\\n", + "0 3.99 21292 26 4.0 4.5 \n", + "1 0.00 161065 26 4.0 3.5 \n", + "2 0.00 188583 2822 3.5 4.5 \n", + "3 0.00 262241 649 4.0 4.5 \n", + "4 0.00 985920 5320 4.5 5.0 \n", + "\n", + " prime_genre \n", + "0 Games \n", + "1 Productivity \n", + "2 Weather \n", + "3 Shopping \n", + "4 Reference " + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "data.head(5)" ] }, { @@ -79,11 +428,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 99, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 7197 entries, 0 to 7196\n", + "Data columns (total 9 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 id 7197 non-null int64 \n", + " 1 track_name 7197 non-null object \n", + " 2 size_bytes 7197 non-null int64 \n", + " 3 price 7197 non-null float64\n", + " 4 rating_count_tot 7197 non-null int64 \n", + " 5 rating_count_ver 7197 non-null int64 \n", + " 6 user_rating 7197 non-null float64\n", + " 7 user_rating_ver 7197 non-null float64\n", + " 8 prime_genre 7197 non-null object \n", + "dtypes: float64(3), int64(4), object(2)\n", + "memory usage: 506.2+ KB\n" + ] + } + ], "source": [ - "# your code here" + "# your code here\n", + "data.info()" ] }, { @@ -95,11 +468,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 100, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "This dataframe has 9 columns.\n" + ] + } + ], "source": [ - "# your code here" + "# your code here\n", + "print(\"This dataframe has\", len(data.columns), \"columns.\")" ] }, { @@ -111,11 +493,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 101, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "['id',\n", + " 'track_name',\n", + " 'size_bytes',\n", + " 'price',\n", + " 'rating_count_tot',\n", + " 'rating_count_ver',\n", + " 'user_rating',\n", + " 'user_rating_ver',\n", + " 'prime_genre']" + ] + }, + "execution_count": 101, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "list(data.columns)" ] }, { @@ -129,11 +531,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 102, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "7197" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "data['id'].count()" ] }, { @@ -147,11 +561,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 103, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "user_rating= data[\"user_rating\"]" ] }, { @@ -165,11 +580,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 104, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3.526955675976101" + ] + }, + "execution_count": 104, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "user_rating.mean()" ] }, { @@ -185,11 +612,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 105, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "user_rating_high = data[data['user_rating'] >= 4]" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The dataframe has 4781 apps with an average rate no less than 4.\n" + ] + } + ], + "source": [ + "# your code here\n", + "user_rating_high= data[data.user_rating >=4]\n", + "print(\"The dataframe has\",user_rating_high[\"id\"].count(), \"apps with an average rate no less than 4.\")\n" ] }, { @@ -201,11 +647,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 107, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4781" + ] + }, + "execution_count": 107, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "len(user_rating_high)" ] }, { @@ -219,11 +677,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 108, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "array(['Games', 'Productivity', 'Weather', 'Shopping', 'Reference',\n", + " 'Finance', 'Music', 'Utilities', 'Travel', 'Social Networking',\n", + " 'Sports', 'Business', 'Health & Fitness', 'Entertainment',\n", + " 'Photo & Video', 'Navigation', 'Education', 'Lifestyle',\n", + " 'Food & Drink', 'News', 'Book', 'Medical', 'Catalogs'],\n", + " dtype=object)" + ] + }, + "execution_count": 108, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "genres= data[\"prime_genre\"].unique()\n", + "genres" ] }, { @@ -235,11 +711,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 109, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "23" + ] + }, + "execution_count": 109, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "len(genres)" ] }, { @@ -260,11 +748,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 110, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Top 3 genres with the most number of apps:\n", + "Games 3862\n", + "Entertainment 535\n", + "Education 453\n", + "Name: prime_genre, dtype: int64\n" + ] + } + ], "source": [ - "# your code here" + "# your code here\n", + "genre_counts = data['prime_genre'].value_counts()\n", + "\n", + "top_3_genres = genre_counts.head(3)\n", + "\n", + "print(\"Top 3 genres with the most number of apps:\")\n", + "print(top_3_genres)\n" ] }, { @@ -305,11 +811,49 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 111, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Genres with the most number of free apps:\n", + "Games 2257\n", + "Entertainment 334\n", + "Photo & Video 167\n", + "Social Networking 143\n", + "Education 132\n", + "Shopping 121\n", + "Utilities 109\n", + "Lifestyle 94\n", + "Finance 84\n", + "Sports 79\n", + "Health & Fitness 76\n", + "Music 67\n", + "Book 66\n", + "Productivity 62\n", + "News 58\n", + "Travel 56\n", + "Food & Drink 43\n", + "Weather 31\n", + "Business 20\n", + "Reference 20\n", + "Navigation 20\n", + "Catalogs 9\n", + "Medical 8\n", + "Name: prime_genre, dtype: int64\n" + ] + } + ], "source": [ - "# your code here" + "# your code here\n", + "free_apps = data[data['price'] == 0.00]\n", + "\n", + "free_genre_counts = free_apps['prime_genre'].value_counts()\n", + "\n", + "print(\"Genres with the most number of free apps:\")\n", + "print(free_genre_counts)\n" ] }, { @@ -352,11 +896,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 112, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Shopping 0.991803\n", + "Catalogs 0.900000\n", + "Social Networking 0.856287\n", + "Finance 0.807692\n", + "News 0.773333\n", + "Sports 0.692982\n", + "Travel 0.691358\n", + "Food & Drink 0.682540\n", + "Lifestyle 0.652778\n", + "Entertainment 0.624299\n", + "Book 0.589286\n", + "Games 0.584412\n", + "Music 0.485507\n", + "Photo & Video 0.478510\n", + "Utilities 0.439516\n", + "Navigation 0.434783\n", + "Weather 0.430556\n", + "Health & Fitness 0.422222\n", + "Business 0.350877\n", + "Productivity 0.348315\n", + "Medical 0.347826\n", + "Reference 0.312500\n", + "Education 0.291391\n", + "Name: prime_genre, dtype: float64" + ] + }, + "execution_count": 112, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "(free_genre_counts / genre_counts).fillna(0).sort_values(ascending=False)\n" ] }, { @@ -397,11 +976,417 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 145, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idtrack_namesize_bytespricerating_count_totrating_count_veruser_ratinguser_rating_verprime_genre
0281656475PAC-MAN Premium1007882243.9921292264.04.5Games
1281796108Evernote - stay organized1585786880.00161065264.03.5Productivity
2281940292WeatherBug - Local Weather, Radar, Maps, Alerts1005240320.0018858328223.54.5Weather
3282614216eBay: Best App to Buy, Sell, Save! Online Shop...1285120000.002622416494.04.5Shopping
4282935706Bible927744000.0098592053204.55.0Reference
..............................
71921187617475Kubik1266442240.00142754.54.5Games
71931187682390VR Roller-Coaster1207603200.0030304.54.5Games
71941187779532Bret Michaels Emojis + Lyric Keyboard1113221121.991504.50.0Utilities
71951187838770VR Roller Coaster World - Virtual Reality972359680.0085324.54.5Games
71961188375727Escape the Sweet Shop Series908984320.00335.05.0Games
\n", + "

7197 rows × 9 columns

\n", + "
" + ], + "text/plain": [ + " id track_name \\\n", + "0 281656475 PAC-MAN Premium \n", + "1 281796108 Evernote - stay organized \n", + "2 281940292 WeatherBug - Local Weather, Radar, Maps, Alerts \n", + "3 282614216 eBay: Best App to Buy, Sell, Save! Online Shop... \n", + "4 282935706 Bible \n", + "... ... ... \n", + "7192 1187617475 Kubik \n", + "7193 1187682390 VR Roller-Coaster \n", + "7194 1187779532 Bret Michaels Emojis + Lyric Keyboard \n", + "7195 1187838770 VR Roller Coaster World - Virtual Reality \n", + "7196 1188375727 Escape the Sweet Shop Series \n", + "\n", + " size_bytes price rating_count_tot rating_count_ver user_rating \\\n", + "0 100788224 3.99 21292 26 4.0 \n", + "1 158578688 0.00 161065 26 4.0 \n", + "2 100524032 0.00 188583 2822 3.5 \n", + "3 128512000 0.00 262241 649 4.0 \n", + "4 92774400 0.00 985920 5320 4.5 \n", + "... ... ... ... ... ... \n", + "7192 126644224 0.00 142 75 4.5 \n", + "7193 120760320 0.00 30 30 4.5 \n", + "7194 111322112 1.99 15 0 4.5 \n", + "7195 97235968 0.00 85 32 4.5 \n", + "7196 90898432 0.00 3 3 5.0 \n", + "\n", + " user_rating_ver prime_genre \n", + "0 4.5 Games \n", + "1 3.5 Productivity \n", + "2 4.5 Weather \n", + "3 4.5 Shopping \n", + "4 5.0 Reference \n", + "... ... ... \n", + "7192 4.5 Games \n", + "7193 4.5 Games \n", + "7194 0.0 Utilities \n", + "7195 4.5 Games \n", + "7196 5.0 Games \n", + "\n", + "[7197 rows x 9 columns]" + ] + }, + "execution_count": 145, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "data" + ] + }, + { + "cell_type": "code", + "execution_count": 169, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
prime_genreaverage_price
10Medical8.776087
1Business5.116316
16Reference4.836875
11Music4.835435
15Productivity4.330562
12Navigation4.124783
3Education4.028234
8Health & Fitness1.916444
0Book1.790536
21Utilities1.647621
22Weather1.605417
6Food & Drink1.552381
14Photo & Video1.473295
7Games1.432923
20Travel1.120370
19Sports0.953070
4Entertainment0.889701
9Lifestyle0.885417
2Catalogs0.799000
13News0.517733
5Finance0.421154
18Social Networking0.339880
17Shopping0.016311
\n", + "
" + ], + "text/plain": [ + " prime_genre average_price\n", + "10 Medical 8.776087\n", + "1 Business 5.116316\n", + "16 Reference 4.836875\n", + "11 Music 4.835435\n", + "15 Productivity 4.330562\n", + "12 Navigation 4.124783\n", + "3 Education 4.028234\n", + "8 Health & Fitness 1.916444\n", + "0 Book 1.790536\n", + "21 Utilities 1.647621\n", + "22 Weather 1.605417\n", + "6 Food & Drink 1.552381\n", + "14 Photo & Video 1.473295\n", + "7 Games 1.432923\n", + "20 Travel 1.120370\n", + "19 Sports 0.953070\n", + "4 Entertainment 0.889701\n", + "9 Lifestyle 0.885417\n", + "2 Catalogs 0.799000\n", + "13 News 0.517733\n", + "5 Finance 0.421154\n", + "18 Social Networking 0.339880\n", + "17 Shopping 0.016311" + ] + }, + "execution_count": 169, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# your code here\n", + "developer= data.groupby([\"prime_genre\"]).agg({\"price\":\"mean\"}).reset_index().sort_values('price', ascending=False).rename(columns={\"price\":\"average_price\"})\n", + "developer" ] }, { @@ -417,7 +1402,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 170, "metadata": {}, "outputs": [], "source": [ @@ -438,11 +1423,147 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 172, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Noyearmonthdayhourpm2.5DEWPTEMPPREScbwdIwsIsIr
012010110NaN-21-11.01021.0NW1.7900
122010111NaN-21-12.01020.0NW4.9200
232010112NaN-21-11.01019.0NW6.7100
342010113NaN-21-14.01019.0NW9.8400
452010114NaN-20-12.01018.0NW12.9700
\n", + "
" + ], + "text/plain": [ + " No year month day hour pm2.5 DEWP TEMP PRES cbwd Iws Is Ir\n", + "0 1 2010 1 1 0 NaN -21 -11.0 1021.0 NW 1.79 0 0\n", + "1 2 2010 1 1 1 NaN -21 -12.0 1020.0 NW 4.92 0 0\n", + "2 3 2010 1 1 2 NaN -21 -11.0 1019.0 NW 6.71 0 0\n", + "3 4 2010 1 1 3 NaN -21 -14.0 1019.0 NW 9.84 0 0\n", + "4 5 2010 1 1 4 NaN -20 -12.0 1018.0 NW 12.97 0 0" + ] + }, + "execution_count": 172, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here:" + "# Your code here:\n", + "pm25.head()" ] }, { @@ -454,7 +1575,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 191, "metadata": {}, "outputs": [], "source": [ @@ -469,7 +1590,7 @@ " '''\n", " \n", " # Your code here:\n", - " " + " return x/24" ] }, { @@ -481,11 +1602,133 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 194, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
IwsIsIr
00.0745830.00.0
10.2050000.00.0
20.2795830.00.0
30.4100000.00.0
40.5404170.00.0
............
438199.6654170.00.0
438209.9075000.00.0
4382110.1125000.00.0
4382210.2800000.00.0
4382310.4104170.00.0
\n", + "

43824 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " Iws Is Ir\n", + "0 0.074583 0.0 0.0\n", + "1 0.205000 0.0 0.0\n", + "2 0.279583 0.0 0.0\n", + "3 0.410000 0.0 0.0\n", + "4 0.540417 0.0 0.0\n", + "... ... ... ...\n", + "43819 9.665417 0.0 0.0\n", + "43820 9.907500 0.0 0.0\n", + "43821 10.112500 0.0 0.0\n", + "43822 10.280000 0.0 0.0\n", + "43823 10.410417 0.0 0.0\n", + "\n", + "[43824 rows x 3 columns]" + ] + }, + "execution_count": 194, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here:" + "# Your code here\n", + "pm_25_hourly= pm25[[\"Iws\",\"Is\",\"Ir\"]].apply(hourly)\n", + "pm_25_hourly" ] }, { @@ -499,9 +1742,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 195, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.00114118303349757" + ] + }, + "execution_count": 195, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def sample_sd(x):\n", " '''\n", @@ -513,7 +1767,12 @@ " Output: 0.3726779962\n", " '''\n", " \n", - " # Your code here:" + " # Your code here: \n", + " count = x.count()\n", + " return np.std(x) / (count - 1)\n", + "\n", + "std_dev = sample_sd(pm25[\"Iws\"])\n", + "std_dev" ] } ], @@ -533,7 +1792,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.10.9" } }, "nbformat": 4,