Question

In: Computer Science

#All the code solutions should only use Pandas/Numpy and Matplotlib. Initialize the US Zipcode dataset as...

#All the code solutions should only use Pandas/Numpy and Matplotlib.

Initialize the US Zipcode dataset as shown below: usZipCodeData = pd.read_csv('http://people.bu.edu/kalathur/datasets/uszips.csv', converters={'zip': lambda x: str(x)})

Q1. Show the top 20 zip codes for Massachusetts by the decreasing order of density attribute.

Q2. Show the top 20 zip codes for Massachusetts by the decreasing order of population attribute.

Q3. What zip codes are common between Q8 and Q9. Use the numpy intersect1d method.

Q4. For Massachusetts, show a scatter plot of latitude versus longitude using color as the log of the population and size as 1/25 of the density.

Q5. For the top 75 populous zip codes in the usZipCodeData, show a pie chart with the distribution of the states and the frequencies of the zip codes in those states. (Hint: Use value_counts. Do not use any aggregate functions not yet covered).

Q6. Using the 7930 as the seed, pick 10 random rows from the Massachusetts data. Show the resulting data frame. Show the horizontal bar chart of the populations with the city as the label.

Solutions

Expert Solution

import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

usZipCodeData = pd.read_csv('http://people.bu.edu/kalathur/datasets/uszips.csv')

usZipCodeData = usZipCodeData.sort_values(by = 'density', ascending = False)# acessing Q2

usZipCodeData = usZipCodeData.sort_values(by = 'population', ascending = False) # Q3

usZipCodeData.head(20)

lat = usZipCodeData["lat"]
lng = usZipCodeData["lng"]
x = []
y = []
x=list(lat)
y=list(lng)
plt.scatter(x,y)
plt.xlabel('lat')
plt.ylabel('lng')
plt.title('Scatter plot for Massachusetts')
plt.show()

Related Solutions

I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data...
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data from a CSV file, which has no names, just numbers. All I did was to read a .csv file. How do I pull data from three columns which contains about 1500 rows with just numbers and make a scatter plot with two in the x-axis and the third in the y-axis?
Use the following dataset and assume all assumptions are met Provide all R code needed to...
Use the following dataset and assume all assumptions are met Provide all R code needed to conduct the tests Bat house color and species Lasiurus in brown: 45, 49, 53, 54, 46, 51, 50, 48, 52, 50 Myotis in brown: 40, 38, 35, 39, 39, 44, 42, 48, 41, 40 Lasiurus in tan: 53, 49, 51, 52, 59, 54, 53, 54, 58, 51 Myotis in tan: 62, 64, 59, 61, 65, 61, 58, 63, 56, 61 Provide the three hypotheses...
The code should be written in c++. It should be in only OpenGL // ***** ONLY...
The code should be written in c++. It should be in only OpenGL // ***** ONLY OpenGL PLEASE ******// write a program snippet that accepts the coordinates of the vertices of a rectangle centered around the origin, with edges that are parallel to the X and Y axes, and with aspect ratio W and converts it into a rectangle centered around the origin with aspect ratio of 1/W. The program has to figure W from the given points. You MUST...
C++ Code each of the following functions RECURSIVELY  (each function should use only the parameter value, and...
C++ Code each of the following functions RECURSIVELY  (each function should use only the parameter value, and any local function variables you might need ..no variables are to be declared outside the functions). void upTo(int number) This function prints all values from 1 up to the number. upTo(5); should output: 1 2 3 4 5 HINT: the following functions involve separating a digit from a number. Use of the arithmetic operators % and / are helpful here. Remember a % 10...
I need this in R code please: Use the dataset ’juul’ in package ’ISwR’ to answer...
I need this in R code please: Use the dataset ’juul’ in package ’ISwR’ to answer the question. (1) Conduct one-way ANOVA test to test if the mean of igf1 of each level of tanner are the same? (2) What is the mean of igf1 in each level of tanner? (3) If there is any difference, which ones appear to be different? (Use pairwise t test for each pair of level with bonferroni method)
For all code assignments there should be exhaustive test code which takes it input from stdin....
For all code assignments there should be exhaustive test code which takes it input from stdin. Your code should be reasonably efficient - it should not have big-Oh larger than what would be expected from good implementation Q1. Implement a double linked list with a sentinel element. The API should have four methods (no more) to: i) A method to create a new list instantiated with some type of elements (data stored in the list) defined at the time the...
Lab - Validate all of the row in the puzzle. // //   - Use this code...
Lab - Validate all of the row in the puzzle. // //   - Use this code as a start of the program. //   - Catch all duplicate entries in each row. //   - Catch any numbers that are not 1 - 9. //   - Display an error msg for each error found. //   - At end, display a msg stating how many errors were found. //===================================================================== import java.util.*; public class Lab_ValidateAllRows    {    public static void main (String[] args)...
Use Titanic dataset and perform EDA on various columns. Without using any modeling algorithms, and only...
Use Titanic dataset and perform EDA on various columns. Without using any modeling algorithms, and only using basic methods such as frequency distribution, describe the most important predictors of survival of Titanic passengers, e.g. were males or females more likely to survive, were young and rich females more likely to survive than old poor males etc? Submit the  response in a fully "knit" R Markdown file.
**** All these methods should be implemented using RECURSIVE solutions (no looping statements) // Java //...
**** All these methods should be implemented using RECURSIVE solutions (no looping statements) // Java // This method takes an integer array as well as an integer (the starting // index) and returns the sum of the squares of the elements in the array. // This method uses recursion. public int sumSquaresRec(int[] A, int pos) { // TODO: implement this method        return -1; // replace this statement with your own return }    // This method takes a...
** Please use only Rstudio and include code ** The target activation force of the buttons...
** Please use only Rstudio and include code ** The target activation force of the buttons on a clicker is 1.967 newtons. Variation exists in activation force due to the nature of the manufacturing process. A sample of 9 clickers showed a mean activation force of 1.88 newtons. The population standard deviation is known to be 0.145 newton. Too much force makes the keys hard to click, while too little force means the keys might be clicked accidentally. We want...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT