Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hello , MY program showing indentation error , could you please verify my code and let m,e know where i am wrong . import pandas

hello ,

MY program showing indentation error , could you please verify my code and let m,e know where i am wrong .

import pandas as pd

import numpy as np

import datetime

def transform(df):

def fix_zip(input_zip):

try:

input_zip = int(float(input_zip))

except:

try:

input_zip = int(input_zip.split('-')[0])

except:

return np.NaN

if input_zip < 10000 or input_zip > 19999:

return np.NaN

return str(input_zip)

df = pd.read_csv('311_data.csv')

df['Incident Zip'] = df['Incident Zip'].apply(fix_zip)

df = df.dropna(how='any',inplace=True)

df = df[df['Borough'] != 'Unspecified']

df['Created Date'] = df['Created Date'].apply(lambda x:datetime.datetime.strptime(x,'%m/%d/%Y %I:%M:%S %p'))

df['Closed Date'] = df['Closed Date'].apply(lambda x:datetime.datetime.strptime(x,'%m/%d/%Y %I:%M:%S %p'))

df['processing_time'] =df['Closed Date'] - df['Created Date']

df = df[df['processing_time']>=datetime.timedelta(0,0,0)]

return df.to_csv('output1.csv')

transform()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

What are aquatic animal?

Answered: 1 week ago

Question

Animals that eat plant is called?

Answered: 1 week ago

Question

The world largest animal?

Answered: 1 week ago

Question

Pet animal example two?

Answered: 1 week ago

Question

The external auditory meatus extends up to?

Answered: 1 week ago