Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!