DEV Community

Durga Pokharel
Durga Pokharel

Posted on

4 2

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

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free