Question

In: Computer Science

I have a CSV file with 6 column Issue id action id Issue category Issue date...

I have a CSV file with 6 column

Issue id action id Issue category Issue date Issue Closed Date Issue Type

Please write a code in Python that counts the number of issues in each category and the earliest and latest issue date for each category.

Example of csv

Issue id action id Issue category Issue date Issue Closed Date Issue Type
23 1 Noise Complaint 7/19/2020 7/22/2020 Client Complaint
24 1 Cleanliness Complaint 7/19/2020 7/23/2020 Sanitation
25 2 Site Inspection 7/20/2020 7/20/2020 Patrol
26 2 Noise Complaint 7/19/2020 7/23/2020 Client Complaint

Solutions

Expert Solution

SAMPLE CSV -

CODE -

import pandas as pd
import datetime
data = pd.read_csv('issue.csv')
data1 = data.groupby('Issue category')
data['Issue date'] = data['Issue date'].apply(lambda v: datetime.datetime.strptime(v, '%m/%d/%Y'))
print("\nIssue Category \t\tNumber of issues")
print(data['Issue category'].value_counts().to_string())
print("\nEarliest Issue Date: \n")
print(data1['Issue date'].min().to_string())
print("\nLatest Issue Date: \n")
print(data1['Issue date'].max().to_string())

SCREENSHOT -


Related Solutions

Language: Python Function name : sort_by_rating Parameters : file (.csv file), category (string), order (boolean) Returns:...
Language: Python Function name : sort_by_rating Parameters : file (.csv file), category (string), order (boolean) Returns: None Description : You want to see what order the items of a particular category in your file would be in if you sorted them by rating. Given a file, a category of clothing, and an order boolean (True for ascending order, False for descending order), create a function that writes a file called “sorted_items.csv” that includes all of the items in the specified...
I am trying to create a program that reads from a csv file and finds the...
I am trying to create a program that reads from a csv file and finds the sum of total volume in liters of liquor sold from the csv file by county and print that list out by county in descending order. Currently my program runs and gives me the right answers but it is not in descending order. I tried this:     for county, volume in sorted(sums_by_volume.items(), key=lambda x: x[1], reverse=True):         index +=1         print("{}. {} {:.2f}".format(county, sums_by_volume[county]))      When I run...
How would I create a nested dictionary given a csv file in Python? Say I want...
How would I create a nested dictionary given a csv file in Python? Say I want to make a dictionary that read {'country':{'China':'Fit', 'China':'Overweight', 'USA': 'Overweight', 'USA': 'Fit', 'England':'Fit'...}, 'category':{'Asian':'Fit', 'Caucasian': 'Overweight', 'Caucasian':'Overweight', 'Asian': 'Fit', 'Middle Eastern': 'Fit'...}} given a file that had country category Weight China Asian Fit China Caucasian Overweight USA Caucasian Overweight USA Asian Fit England Middle Eastern Fit... ... And so on in the file.
How do I write a C++ program to call a frequency table from a csv file,...
How do I write a C++ program to call a frequency table from a csv file, using vector? Data given is in a csv file. Below is part of the sample data. Student ID English Math Science 100000100 80 90 90 100000110 70 60 70 100000120 80 100 90 100000130 60 60 60 100000140 90 80 80
{PYTHON }You have a CSV file containing the location and population of various cities around the...
{PYTHON }You have a CSV file containing the location and population of various cities around the world. For this question you'll be given a list of cities and return the total population across all those cities. Write a function named "total_population" that takes a string then a list as parameters where the string represents the name of a CSV file containing city data in the format "CountryCode,CityName,Region,Population,Latitude,Longitude" and the second parameter is a list where each element is itself a...
{PYTHON }You have a CSV file containing the location and population of various cities around the...
{PYTHON }You have a CSV file containing the location and population of various cities around the world. For this question you'll be given a list of cities and return the total population across all those cities. Write a function named "total_population" that takes a string then a list as parameters where the string represents the name of a CSV file containing city data in the format "CountryCode,CityName,Region,Population,Latitude,Longitude" and the second parameter is a list where each element is itself a...
C programming: Assume you have the following spreadsheet as example.csv. This .csv file can have more...
C programming: Assume you have the following spreadsheet as example.csv. This .csv file can have more than 1000 lines of data. time latitude longitude depth mag 2020-10-19T23:28:33.400Z 61.342 -147.3997 12.3 1.6 2020-10-19T23:26:49.460Z 38.838501 -122.82684 1.54 0.57 2020-10-19T23:17:28.720Z 35.0501667 -117.6545 0.29 1.51 2020-10-19T22:47:44.770Z 38.187 -117.7385 10.8 1.5 2020-10-19T22:42:26.224Z 54.4198 -159.9943 18.7 2.9 2020-10-19T22:39:38.900Z 18.004 -66.761 14 2.87 Read the spreadsheet which is example.csv file in your new c program and then sort the above data by latitude in ascending order. Use...
You have a table called scholar where there are two fields id and create date. You...
You have a table called scholar where there are two fields id and create date. You want to create an ETL process that loads the data from scholar table into the big data platform. What are the different things that you will put on a requirement document for the developer to write code and implement the solution?
I. Company A issues bonds with a par value of $870,000 on their stated issue date....
I. Company A issues bonds with a par value of $870,000 on their stated issue date. The bonds mature in five years and pay 8% annual interest in semiannual payments. Assume: On the issue date, the annual market rate for the bonds is 6%. What is the amount of each semiannual interest payment for these bonds? _________________ Compute the price of the bonds as of their issue date using either the factors tables or excel formula. _________________ Prepare the journal...
I. Company A issues bonds with a par value of $870,000 on their stated issue date....
I. Company A issues bonds with a par value of $870,000 on their stated issue date. The bonds mature in five years and pay 8% annual interest in semiannual payments. Assume: On the issue date, the annual market rate for the bonds is 10%. What is the amount of each semiannual interest payment for these bonds? _________________ Compute the price of the bonds as of their issue date using either the factor tables or excel formula.    _________________ Prepare the journal...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT