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 to read a csv file in php and make a html table? I can't use...
how to read a csv file in php and make a html table? I can't use the PHP function fgetcsv. I can use explode. I can't put a php inside a php. Acme,Walmart,Ross,BJs,Target,Marshalls,Foot Locker,Giant,Charming Charlie 142,160,28,10,5,3,60,0.28,3167 175,180,18,8,4,1,12,0.43,4033 129,132,13,6,3,1,41,0.33,1471 138,140,17,7,3,1,22,0.46,3204 232,240,25,8,4,3,5,2.05,3613 135,140,18,7,4,3,9,0.57,3028 150,160,20,8,4,3,18,4.00,3131 207,225,22,8,4,2,16,2.22,5158 271,285,30,10,5,2,30,0.53,5702 89,90,10,5,3,1,43,0.30,2054 153,157,22,8,3,3,18,0.38,4127 87,90,16,7,3,1,50,0.65,1445 234,238,25,8,4,2,2,1.61,2087 106,116,20,8,4,1,13,0.22,2818 175,180,22,8,4,2,15,2.06,3917 165,170,17,8,4,2,33,0.46,2220 166,170,23,9,4,2,37,0.27,3498 136,140,19,7,3,1,22,0.63,3607 <!DOCTYPE html> <html> <head>    <meta charset="utf-8">    <title>Stores</title>    <link rel="stylesheet" href="style.css"> </head> <body> <h1>Stores</h1> <?php <table> <tr> <th>Acme</th> <th>Walmart</th> <th>Ross</th> <th>BJs</th> <th>Target</th> <th>Marshalls</th> <th>Foot Locker</th>...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT