Created
May 11, 2017 02:16
-
-
Save princebot/0baff68f0d8df105ea7159d3fe343e01 to your computer and use it in GitHub Desktop.
Editing a friend's script for Python style.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Parse RideAustin data from https://data.world/andytryba/rideaustin/file/RideAustin_Weather.csv | |
""" | |
import argparse | |
import pandas | |
from dateutil import parser | |
def main(): | |
cli = argparse.ArgumentParser(description=__doc__) | |
cli.add_argument( | |
'start_date', | |
type=parser.parse, | |
help='Beginning of date range, e.g., "Dec 1 2016"') | |
cli.add_argument( | |
'end_date', | |
type=parser.parse, | |
help='End of date range, e.g., "Dec 5 2016"') | |
args = cli.parse_args() | |
ride_data = pandas.read_csv( | |
'RideAustin_Weather.csv', | |
dtype=object, | |
parse_dates=['completed_on', 'started_on', 'Date']) | |
frame = ride_data[ | |
(ride_data['started_on'] > args.start_date) & | |
(ride_data['started_on'] <= args.end_date) | |
] | |
frame.to_csv('Selecta.csv') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment