Skip to content

Instantly share code, notes, and snippets.

@mj-ml
Created June 16, 2024 21:22
Show Gist options
  • Select an option

  • Save mj-ml/aed3d1fa0601e519ca412edbb8c699c5 to your computer and use it in GitHub Desktop.

Select an option

Save mj-ml/aed3d1fa0601e519ca412edbb8c699c5 to your computer and use it in GitHub Desktop.
categorical = ['PULocationID', 'DOLocationID']
def read_data(filename):
df = pd.read_parquet(filename)
df['duration'] = df.tpep_dropoff_datetime - df.tpep_pickup_datetime
df['duration'] = df.duration.dt.total_seconds() / 60
df = df[(df.duration >= 1) & (df.duration <= 60)].copy()
df[categorical] = df[categorical].fillna(-1).astype('int').astype('str')
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment