<commit_before>import pandas as pd

class TripSubset(pd.DataFrame):
    def by_station(self):
        started = self.groupby("start_station").size()
        ended = self.groupby("end_station").size()
        counts = pd.DataFrame({
            "trips_started": started,
            "trips_ended": ended,
            "trips_total": started + ended
        })
        return counts.reindex(counts.index.rename("station_id")).reset_index()

    def by_interval(self, interval, interval_name):
        counts = self.set_index("start_time")["bike_id"]\
            .resample(interval, how=len)
        return pd.DataFrame({
            "trips_total": counts
        }).reindex(counts.index.rename(interval_name))

    def by_day(self): return self.by_interval("D", "day")

    def by_month(self): return self.by_interval("MS", "month")
    
class BikeShareProgram(object):
    def __init__(self):
        self.trips = None
        self.stations = None

    def load_trips(self, *args, **kwargs):
        self.trips = TripSubset(self.parse_trips(*args, **kwargs))<commit_msg>Add get_time_range<commit_after>import pandas as pd

class TripSubset(pd.DataFrame):
    def by_station(self):
        started = self.groupby("start_station").size()
        ended = self.groupby("end_station").size()
        counts = pd.DataFrame({
            "trips_started": started,
            "trips_ended": ended,
            "trips_total": started + ended
        })
        return counts.reindex(counts.index.rename("station_id")).reset_index()

    def by_interval(self, interval, interval_name):
        counts = self.set_index("start_time")["bike_id"]\
            .resample(interval, how=len)
        return pd.DataFrame({
            "trips_total": counts
        }).reindex(counts.index.rename(interval_name))

    def by_day(self): return self.by_interval("D", "day")

    def by_month(self): return self.by_interval("MS", "month")

    def get_time_range(self, event="start"):
        times = self[event + "_time"]
        return (times.min(), times.max())
    
class BikeShareProgram(object):
    def __init__(self):
        self.trips = None
        self.stations = None

    def load_trips(self, *args, **kwargs):
        self.trips = TripSubset(self.parse_trips(*args, **kwargs))
{'fraction_non_alphanumeric': 0.1375055090348171, 'fraction_numerical': 0.0, 'mean_word_length': 2.886986301369863, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6679002', 'n_tokens_mistral': 717, 'n_tokens_neox': 708, 'n_words': 131}