Problem Statement
A cryptocurrency is a digital or virtual currency that is protected by encryption, making counterfeiting and double-spending practically impossible. Many cryptocurrencies are built on blockchain technology, which is a distributed ledger enforced by a distributed network of computers.
In this Scenario, You are supposed to perform an EDA and Visualization on Top100 list of Cryptocurrencies dataset.
Dataset – Data.csv
Note: Incase if you getting any permission denied error for dataset in the Jupyter Notebook. Then you can download the dataset from the above ‘Data.csv’ file, save it as Data.csv and then upload it into IDE.
Dataset Description
| Column Name | Description |
|---|---|
| Rank | Rank of the Currency |
| Currency_Name | Name of the Currency |
| Market_Capital | It is an indicator of the dominance and popularity of cryptocurrencies. |
| Price | The price of Cryptocurrency |
| Circulating_Supply | It is the number of cryptocurrency coins or tokens that are publicly available and circulating in the market. |
| Volume(24h) | It is the number of coins that have exchanged hands during 24 hours. |
| Change(24h) | It is difference between the current price and the price 24 hours ago. |
Testing the Solutions:
After completing the solution, Test it by clicking File -> New -> Terminal, run the following commands
$ pip3 install pytest
$ pytest -s tests_sample.py
Import the library and Dataset
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
url = "https://hr-projects-assets-prod.s3.amazonaws.com/ct7fl6bona6/b1093f2c1c57d266329c1cce18ee34ad/Data.csv"
df = pd.read_csv(url)
df.head(1)
Question 1: convert dataframe into dictionary.
Extract the first 3 rows of your dataframe then convert it into dictionary with the column names as the key values and their values as list into a dictionary, then assign to A1 variable.
Note: The output must be in the following format
{Column_Name : List}
"""
Example:
{ 'S.no' : [1,2,3,4],
'Name' : ['GridCoin','Golos','BlackCion','Groestlcoin'],
........}
"""
#Write your code here
A1 = df[:3].to_dict(orient="list")
A1
"""
Output:
{'Rank': [1, 2, 3],
'Currency_Name': ['Bitcoin', 'Ethereum', 'Bitcoin Cash'],
'Market_Capital': [60219183594.0, 25061275598.0, 6815417939.0],
'Price': [3631.72, 264.44, 410.47],
'Circulating_Supply': [16581450.0, 94772198.0, 16603775.0],
'Volume(24h)': [1226800000.0, 462576000.0, 260857000.0],
'Change(24h)': [-0.0084, 0.0132,-0.0322]}
"""
Question 2 Filter highest Price.
Return the Curreny_Name which has highest value in Price column and assign to A2 variable.
Note: The Output must be String
#Write your code here
A2= df.loc[df["Price"].idxmax(), "Currency_Name"]
A2
#'Bitcoin
Question 3: Find the mean of "Change(24h)" column.
Return the mean value of the Change(24h) column and assign to A3 variable.
Note: The Output must be Float value
#Write your code here
A3=df["Change(24h)"].mean()
A3
#0.013364000000000003
Question 4. Filter multiple columns.
Return the sorted (Ascending order) list of currency names which are having "Market_Capital" greater than ‘2000000000’ and Price greater than or equal to
‘200’. Assign to A4 variable.
Note: The Output must be list
#Write your code
A4=df[ (df["Market_Capital"]> 2000000000) & (df["Price"]>=200)]["Currency_Name"].sort_values().to_list()
A4
#['Bitcoin', 'Bitcoin Cash', 'Dash', 'Ethereum']
Question 5. Find the minimum value of "Volume(24h)" column.
Return the lowest value in Volume(24h) column and Assign to A5 variable.
Note: Output must be Float value.
#Write your code here
A5= df["Volume(24h)"].min()
A5
# 4460.0
Question 6. Draw the Heatmap.
Draw the Heatmap with correlation between Rank, Marcket Captial, Price, Circulating_Supply, Volume(24h) and Change(24h). Assign to A6 variable.
-
Instructions:
- Use seaborn
- Create a figure with figsize(15,8)
- xlabel,ylabel,title must be present
- Plot the heatmap
#Write your code here
fig, ax = plt.subplots(figsize=(8,8))
col = ['Rank', 'Market_Capital', 'Price', 'Circulating_Supply', 'Volume(24h)','Change(24h)']
corr = df[col].corr()
# Plot the Heatmap with axes (ax) and assign the returned object(path collection) to q6
q6 = sns.heatmap(corr,annot=True, fmt=".2f", ax=ax)
ax.set_xlabel("X-axis")
ax.set_ylabel("Y-axis")
ax.set_title("Heatmap Correlation")
#Assigning the object to A6 for validation
A6=q6
Question 7. Draw the barplot
Draw the barplot containing Top 10 currency names with highest Market Capital And Assign to A7 variable.
- Instructions:
- Use Seaborn
- Order the cryptocurrencies is must be in Descending order (i.e,bar corresponding to cryptocurrency with highest market value must be on top of bar plot).
- xlabel,ylabel,title must be present
- Plot the barplot
#Write your code here
fig7, ax7 = plt.subplots(figsize=(8,8))
d = df.nlargest(10, "Market_Capital")
# Plot the countplot with axes (ax7) and assign the returned object(path collection) to q7
q7 = sns.barplot(data=d, x="Market_Capital", y="Currency_Name" , order=d.sort_values("Market_Capital", ascending=False)["Currency_Name"], ax= ax7)
ax7.set_xlabel("Market_Capital")
ax7.set_title("Barplot containing Top10 Currency names with highest market capital")
ax7.set_ylabel("Currency_Name")
#Assigning the object,axes to A7 for validation
A7=[q7,ax7]
Question 8. Draw the violinplot.
Draw the violinplot that represents the graph of Change(24h), and Assign the variable to A8.
- Instructions:
- Use seaborn
- Change(24h) should be in the y-axis- xlabel,ylabel,title must be present
- Plot the violinplot
#Write your code here
fig8, ax8 = plt.subplots(figsize=(8,8))
# Plot the violinplot with axes (ax8) and assign the returned object(path collection) to q8
q8 = sns.violinplot(data=df, y="Change(24h)")
ax8.set_xlabel("X_axis")
ax8.set_title("violinplot for Change(24h)")
ax8.set_ylabel("Y-axis")
#Assigning the object to A8 for validation
A8=q8
Question 9. Draw a relation scatterplot.
Draw a scatterplot that represents the relation between Price and Market Capital. And Assign to A9 variable.
-
Instructions:
- use seaborn
- Consider data as 50 Cryptocurrencies, with higest Market Value
- xlabel,ylabel,title must be present
- Plot the Scatterplot
#Write your code here
fig9, ax9 = plt.subplots(figsize=(8,8))
# Plot the scatterplot with axes (ax9) and assign the returned object(path collection) to q9
q9 = sns.scatterplot(data=df.nlargest(50, "Market_Capital"),x="Market_Capital", y= "Price", ax =ax9)
ax9.set_xlabel("Market_Capital")
ax9.set_title("scatterplot between Price and Market Capital")
ax9.set_ylabel("Price")
A9=q9
Question 10. Draw the barplot with Top 10 currency names.
Draw the barplot containing Top 10 currency names with Change(24h) in descending order And Assign to A10 variable.
Instructions:
- Use Seaborn
- xlabel,ylabel,title must be present
- Plot the barplot
#Write your code here
fig10, ax10 = plt.subplots(figsize=(8,8))
# Plot the barplot with axes (ax10) and assign the returned object(path collection) to q10
q10 = sns.barplot(data=df.nlargest(10, "Change(24h)"), x="Change(24h)",y="Currency_Name", ax=ax10)
ax10.set_xlabel("Change(24h)")
ax10.set_title("Barplot containing Top10 Currency names with Change(24h)")
ax10.set_ylabel("Currency_Name")
#Assigning the object,axes to A10 for validation
A10=[q10,ax10]