DEV Community

Durga Pokharel
Durga Pokharel

Posted on

Day 73 Of 100DaysOfCode: Data Visualization

This is my 73th day of #100daysofcode and #python learning. Today, I keep learning from Datacamp and also completed some assignments. Also, I am present in one bootcamp from dphi where I did data visualization on data given on assignment, which contained some metropolitan data and publicly available here.

After I got Hawkins Fellowship, I am learning from Datacamp because I have access to most courses there now. Hence my journey of learning Algorithms from Coursera is in pending state. I am going to write some of assignments I completed today.

dphi Assignment

All the assignments were quizz but I had to write code in order to find the right answer and it was quite fun to try.

I started by reading CSV file using Pandas.

import pandas as pd
%matplotlib inline
data = pd.read_csv("https://raw.githubusercontent.com/dphi-official/Assignment_Solutions/master/Standard%20Metropolitan%20Areas%20Data%20-%20train_data%20-%20data.csv")
data.head()
Enter fullscreen mode Exit fullscreen mode

Question 1: What is the Mean area of lands?

Not that hard, just take mean.

data.land_area.mean()
Enter fullscreen mode Exit fullscreen mode

Output of the code is,

2615.7272727272725
Enter fullscreen mode Exit fullscreen mode

Question 2: What is the crime rate among all Metropolitan Areas?

Again it is the max value of single column.

data.crime_rate.max()
Enter fullscreen mode Exit fullscreen mode

Output of the code is,

85.62
Enter fullscreen mode Exit fullscreen mode

Question 3: What is the average crime rate among all metropolitan areas?

Same as previous, find mean of single column.

data.crime_rate.mean()
Enter fullscreen mode Exit fullscreen mode

Output of the above code is,

55.64303030303031
Enter fullscreen mode Exit fullscreen mode

Question 4: What is the top 5 data of region 4?

Just do boolean masking.

data[data.region==4]
Enter fullscreen mode Exit fullscreen mode

More

I have uploaded a fully loaded notebook here


Day 73 Of #100DaysOfCode and #Python
Data Visualization#100DaysOfCode #WomenWhoCode #CodeNewbies #beginner #DEVCommunity pic.twitter.com/RF3dNCgAkm

— Durga Pokharel (@mathdurga) March 11, 2021

Top comments (0)