{"cells":[{"cell_type":"markdown","source":"## 1. Bitcoin. Cryptocurrencies. So hot right now.\n

Since the launch of Bitcoin in 2008, hundreds of similar projects based on the blockchain technology have emerged. We call these cryptocurrencies (also coins or cryptos in the Internet slang). Some are extremely valuable nowadays, and others may have the potential to become extremely valuable in the future1. In fact, the 6th of December of 2017 Bitcoin has a market capitalization above $200 billion.

\n

*1- WARNING: The cryptocurrency market is exceptionally volatile and any money you put in might disappear into thin air. Cryptocurrencies mentioned here might be scams similar to Ponzi Schemes or have many other issues (overvaluation, technical, etc.). Please do not mistake this for investment advice. *

\n

That said, let's get to business. As a first task, we will load the current data from the coinmarketcap API and display it in the output.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"4"}}},{"cell_type":"code","execution_count":229,"source":"# Importing pandas\nimport pandas as pd\n\n# Importing matplotlib and setting aesthetics for plotting later.\nimport matplotlib.pyplot as plt\n%matplotlib inline\n%config InlineBackend.figure_format = 'svg' \nplt.style.use('fivethirtyeight')\n\n# Reading in current data from coinmarketcap.com\ncurrent = pd.read_json(\"https://api.coinmarketcap.com/v1/ticker/\")\n\n# Printing out the first few lines\n# ... YOUR CODE FOR TASK 1 ...\nprint(current.head())","outputs":[{"output_type":"stream","name":"stdout","text":" 24h_volume_usd available_supply id last_updated \\\n0 11592000000 16802450 bitcoin 1515941661 \n1 5318660000 96975914 ethereum 1515941649 \n2 1930340000 38739142811 ripple 1515941641 \n3 1026610000 16911375 bitcoin-cash 1515941651 \n4 177501000 25927070538 cardano 1515941654 \n\n market_cap_usd max_supply name percent_change_1h \\\n0 230133076180 2.100000e+07 Bitcoin 0.09 \n1 128785953683 NaN Ethereum -0.51 \n2 72220996551 1.000000e+11 Ripple -0.82 \n3 43428072773 2.100000e+07 Bitcoin Cash -0.25 \n4 20143804111 4.500000e+10 Cardano -1.72 \n\n percent_change_24h percent_change_7d price_btc price_usd rank \\\n0 -5.53 -17.84 1.000000 13696.400000 1 \n1 -2.58 18.08 0.097010 1328.020000 2 \n2 -7.84 -43.99 0.000136 1.864290 3 \n3 -6.80 -12.13 0.187587 2567.980000 4 \n4 -9.87 -23.59 0.000057 0.776941 5 \n\n symbol total_supply \n0 BTC 16802450 \n1 ETH 96975914 \n2 XRP 99993093880 \n3 BCH 16911375 \n4 ADA 31112483745 \n"}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"4"}}},{"cell_type":"markdown","source":"## 2. Full dataset, filtering, and reproducibility\n

The previous API call returns only the first 100 coins, and we want to explore as many coins as possible. Moreover, we can't produce reproducible analysis with live online data. To solve these problems, we will load a CSV we conveniently saved on the 6th of December of 2017 using the API call https://api.coinmarketcap.com/v1/ticker/?limit=0 named coinmarketcap_06122017.csv.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"11"}}},{"cell_type":"code","execution_count":231,"source":"import os\n\n# Reading datasets/coinmarketcap_06122017.csv into pandas\ndec6 = pd.read_csv('./datasets/coinmarketcap_06122017.csv')\n\n# Selecting the 'id' and the 'market_cap_usd' columns\nmarket_cap_raw = dec6[[\"id\", \"market_cap_usd\"]]\n\n# Counting the number of values\n# ... YOUR CODE FOR TASK 2 ...\nprint(market_cap_raw.count())","outputs":[{"output_type":"stream","name":"stdout","text":"id 1326\nmarket_cap_usd 1031\ndtype: int64\n"}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"11"}}},{"cell_type":"markdown","source":"## 3. Discard the cryptocurrencies without a market capitalization\n

Why do the count() for id and market_cap_usd differ above? It is because some cryptocurrencies listed in coinmarketcap.com have no known market capitalization, this is represented by NaN in the data, and NaNs are not counted by count(). These cryptocurrencies are of little interest to us in this analysis, so they are safe to remove.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"18"}}},{"cell_type":"code","execution_count":233,"source":"# Filtering out rows without a market capitalization\ncap = market_cap_raw.query('market_cap_usd > 0')\n\n# Counting the number of values again\n# ... YOUR CODE FOR TASK 3 ...\nprint(cap.count())","outputs":[{"output_type":"stream","name":"stdout","text":"id 1031\nmarket_cap_usd 1031\ndtype: int64\n"}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"18"}}},{"cell_type":"markdown","source":"## 4. How big is Bitcoin compared with the rest of the cryptocurrencies?\n

At the time of writing, Bitcoin is under serious competition from other projects, but it is still dominant in market capitalization. Let's plot the market capitalization for the top 10 coins as a barplot to better visualize this.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"25"}}},{"cell_type":"code","execution_count":235,"source":"#Declaring these now for later use in the plots\nTOP_CAP_TITLE = 'Top 10 of market capitalization'\nTOP_CAP_YLABEL = '% of total cap'\n\n# Selecting the first 10 rows and setting the index\ncap10 = cap[0:10].set_index(\"id\")\n\n# Calculating market_cap_perc\ntotal_market_cap = cap.market_cap_usd.sum()\ncap10 = cap10.assign(market_cap_perc = lambda x: 100*x / total_market_cap)\n\n# Plotting the barplot with the title defined above \nax = cap10.market_cap_perc.plot.bar(title=\"Top 10 of market capitalization\")\n\n# Annotating the y axis with the label defined above\n# ... YOUR CODE FOR TASK 4 ...\nax.set(ylabel=\"% of total cap\")","outputs":[{"metadata":{},"execution_count":235,"output_type":"execute_result","data":{"text/plain":"[Text(0,0.5,'% of total cap')]"}},{"metadata":{},"output_type":"display_data","data":{"image/svg+xml":"\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n","text/plain":""}}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"25"}}},{"cell_type":"markdown","source":"## 5. Making the plot easier to read and more informative\n

While the plot above is informative enough, it can be improved. Bitcoin is too big, and the other coins are hard to distinguish because of this. Instead of the percentage, let's use a log10 scale of the \"raw\" capitalization. Plus, let's use color to group similar coins and make the plot more informative1.

\n

For the colors rationale: bitcoin-cash and bitcoin-gold are forks of the bitcoin blockchain2. Ethereum and Cardano both offer Turing Complete smart contracts. Iota and Ripple are not minable. Dash, Litecoin, and Monero get their own color.

\n

1 This coloring is a simplification. There are more differences and similarities that are not being represented here.

\n

2 The bitcoin forks are actually very different, but it is out of scope to talk about them here. Please see the warning above and do your own research.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"32"}}},{"cell_type":"code","execution_count":237,"source":"# Colors for the bar plot\nCOLORS = ['orange', 'green', 'orange', 'cyan', 'cyan', 'blue', 'silver', 'orange', 'red', 'green']\n\n# Plotting market_cap_usd as before but adding the colors and scaling the y-axis \nax = cap10.market_cap_perc.plot.bar(title=\"Top 10 of market capitalization\", color = COLORS)\nax.set_yscale(\"log\")\n\n# Annotating the y axis with 'USD'\n# ... YOUR CODE FOR TASK 5 ...\nax.set_ylabel(\"USD\")\n\n# Final touch! Removing the xlabel as it is not very informative\n# ... YOUR CODE FOR TASK 5 ...\nax.set_xlabel(\"\")","outputs":[{"metadata":{},"execution_count":237,"output_type":"execute_result","data":{"text/plain":"Text(0.5,0,'')"}},{"metadata":{},"output_type":"display_data","data":{"image/svg+xml":"\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n","text/plain":""}}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"32"}}},{"cell_type":"markdown","source":"## 6. What is going on?! Volatility in cryptocurrencies\n

The cryptocurrencies market has been spectacularly volatile since the first exchange opened. This notebook didn't start with a big, bold warning for nothing. Let's explore this volatility a bit more! We will begin by selecting and plotting the 24 hours and 7 days percentage change, which we already have available.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"39"}}},{"cell_type":"code","execution_count":239,"source":"# Selecting the id, percent_change_24h and percent_change_7d columns\nvolatility = dec6[[\"id\", \"percent_change_24h\", \"percent_change_7d\"]]\n\n# Setting the index to 'id' and dropping all NaN rows\nvolatility = volatility.set_index(\"id\").dropna()\n\n# Sorting the DataFrame by percentage_change_24h in ascending order\nvolatility = volatility.sort(\"percent_change_24h\", ascending=True)\n\n# Checking the first few rows\n# ... YOUR CODE FOR TASK 6 ...\nprint(volatility.head())","outputs":[{"output_type":"stream","name":"stdout","text":" percent_change_24h percent_change_7d\nid \nflappycoin -95.85 -96.61\ncredence-coin -94.22 -95.31\ncoupecoin -93.93 -61.24\ntyrocoin -79.02 -87.43\npetrodollar -76.55 542.96\n"}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"39"}}},{"cell_type":"markdown","source":"## 7. Well, we can already see that things are *a bit* crazy\n

It seems you can lose a lot of money quickly on cryptocurrencies. Let's plot the top 10 biggest gainers and top 10 losers in market capitalization.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"46"}}},{"cell_type":"code","execution_count":241,"source":"#Defining a function with 2 parameters, the series to plot and the title\ndef top10_subplot(volatility_series, title):\n # Making the subplot and the figure for two side by side plots\n fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 6))\n \n # Plotting with pandas the barchart for the top 10 losers\n ax = volatility_series[:10].plot.bar(ax=axes[0], color=\"darkred\")\n \n # Setting the figure's main title to the text passed as parameter\n # ... YOUR CODE FOR TASK 7 ...\n fig.suptitle(title)\n \n # Setting the ylabel to '% change'\n # ... YOUR CODE FOR TASK 7 ...\n axes[0].set_ylabel(\"% change\")\n \n # Same as above, but for the top 10 winners\n ax = volatility_series[-10:].plot.bar(ax=axes[1], color=\"darkblue\")\n \n # Returning this for good practice, might use later\n return fig, ax\n\nDTITLE = \"24 hours top losers and gainers\"\n\n# Calling the function above with the 24 hours period series and title DTITLE \nfig, ax = top10_subplot(volatility.percent_change_24h, DTITLE)","outputs":[{"metadata":{},"output_type":"display_data","data":{"image/svg+xml":"\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n","text/plain":""}}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"46"}}},{"cell_type":"markdown","source":"## 8. Ok, those are... interesting. Let's check the weekly Series too.\n

800% daily increase?! Why are we doing this tutorial and not buying random coins?1

\n

After calming down, let's reuse the function defined above to see what is going weekly instead of daily.

\n

1 Please take a moment to understand the implications of the red plots on how much value some cryptocurrencies lose in such short periods of time

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"53"}}},{"cell_type":"code","execution_count":243,"source":"# Sorting in ascending order\nvolatility7d = volatility.sort(\"percent_change_7d\", ascending=True)\n\nWTITLE = \"Weekly top losers and gainers\"\n\n# Calling the top10_subplot function\nfig, ax = top10_subplot(volatility7d.percent_change_7d, WTITLE)","outputs":[{"metadata":{},"output_type":"display_data","data":{"image/svg+xml":"\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n","text/plain":""}}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"53"}}},{"cell_type":"markdown","source":"## 9. How small is small?\n

The names of the cryptocurrencies above are quite unknown, and there is a considerable fluctuation between the 1 and 7 days percentage changes. As with stocks, and many other financial products, the smaller the capitalization, the bigger the risk and reward. Smaller cryptocurrencies are less stable projects in general, and therefore even riskier investments than the bigger ones1. Let's classify our dataset based on Investopedia's capitalization definitions for company stocks.

\n

1 Cryptocurrencies are a new asset class, so they are not directly comparable to stocks. Furthermore, there are no limits set in stone for what a \"small\" or \"large\" stock is. Finally, some investors argue that bitcoin is similar to gold, this would make them more comparable to a commodity instead.

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"60"}}},{"cell_type":"code","execution_count":245,"source":"# Selecting everything bigger than 10 billion \nprint(cap.dtypes)\nlargecaps = cap.query(\"market_cap_usd > 10000000000\")\n\n# Printing out largecaps\n# ... YOUR CODE FOR TASK 9 ...\nprint(largecaps)","outputs":[{"output_type":"stream","name":"stdout","text":"id object\nmarket_cap_usd float64\ndtype: object\n id market_cap_usd\n0 bitcoin 2.130493e+11\n1 ethereum 4.352945e+10\n2 bitcoin-cash 2.529585e+10\n3 iota 1.475225e+10\n"}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"60"}}},{"cell_type":"markdown","source":"## 10. Most coins are tiny\n

Note that many coins are comparable to large companies in market cap, so let's divert from the original Investopedia definition by merging categories.

\n

This is all for now. Thanks for doing this project!

","metadata":{"editable":false,"tags":["context"],"deletable":false,"run_control":{"frozen":true},"dc":{"key":"67"}}},{"cell_type":"code","execution_count":247,"source":"# Making a nice function for counting different marketcaps from the\n# \"cap\" DataFrame. Returns an int.\n# INSTRUCTORS NOTE: Since you made it to the end, consider it a gift :D\ndef capcount(query_string):\n return cap.query(query_string).count().id\n\n# Labels for the plot\nLABELS = [\"biggish\", \"micro\", \"nano\"]\n\n# Using capcount count the biggish cryptos\nbiggish = capcount(\"market_cap_usd > 300000000\")\n\n# Same as above for micro ...\nmicro = capcount(\"market_cap_usd > 50000000 & market_cap_usd < 300000000\")\n\n# ... and for nano\nnano = capcount(\"market_cap_usd < 50000000\")\n\n# Making a list with the 3 counts\nvalues = [biggish, micro, nano]\n\n# Plotting them with matplotlib \n# ... YOUR CODE FOR TASK 10 ... \nplt.bar(LABELS, values)","outputs":[{"metadata":{},"execution_count":247,"output_type":"execute_result","data":{"text/plain":""}},{"metadata":{},"output_type":"display_data","data":{"image/svg+xml":"\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n","text/plain":""}}],"metadata":{"trusted":true,"tags":["sample_code"],"dc":{"key":"67"}}}],"nbformat_minor":2,"nbformat":4,"metadata":{"kernelspec":{"language":"python","name":"python3","display_name":"Python 3"},"language_info":{"pygments_lexer":"ipython3","codemirror_mode":{"name":"ipython","version":3},"name":"python","version":"3.5.2","nbconvert_exporter":"python","file_extension":".py","mimetype":"text/x-python"}}}