Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import pandas as pd def load _ ticket _ data ( ) : file _ paths 'AnnArbor - TicketViolation 2 0 1 7 . xIs',
import pandas as pd
def loadticketdata:
filepaths
'AnnArborTicketViolationxIs',
'AnnArborTicketViolationjanxIs',
'AnnArborTicketViolationxIs',
'AnnArborTicketViolationxIs',
'AnnArborTicketViolationxIs',
'AnnArborTicketViolationxIs'
dflist
totalrows
for filepath in filepaths:
if in filepath:
df pdreadcsvfilepath, header skipfooter # Skip footer row for
else:
xls ExcelFilefilepath
sheetsnamesxlssheetnames
dfpdDataFrame
for sheetname in sheetnames:
sheetdfpdreadexcelfilepath, sheetnamesheetname, headerNone, skipfooter
if sheetname in Sheet 'Sheet and sheetdfcolumns: sheetdf sheetdfiloc: # Skip the first row for sheet and sheet of pdconcatdf sheetdf ignoreindexTrue
totalrows lendf
if in filepath:
dfrenamecolumns Fine : "Fine" inplaceTrue
else:
dfcolumns
'Ticket # 'Badge', 'Issue Date', 'IssueTime', 'Plate', 'State',
'Make', 'Model', 'Violation', 'Description', 'Location', 'Meter',
'Fine', 'Penalty'
dflist.appenddf
fulldf pdconcatdflist, ignoreindexTrue
if totalrows lenfulldf:
printTotal rows do not match the number of rows in the concatenated DataFrame."
return fulldf
# Testing the function
dftest loadticketdata
printTotal number of rows in all files:", lendftest
Cannot get correct answer
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started