<jupyter_start><jupyter_text>Load feeds for March.<jupyter_code># f20_mar = gtfs_kit_scissors.cut_dates(gk.read_feed(paths[2020], dist_units='km'), ["20200301","20200331"], validate=False)
f20_mar = gk.read_feed(paths[2020], dist_units='km').restrict_to_dates(["20200301","20200331"])
# f21_mar = gtfs_kit_scissors.cut_dates(gk.read_feed(paths[2021], dist_units='km'), ["20210301","20210331"], validate=False)
f21_mar = gk.read_feed(paths[2021], dist_units='km').restrict_to_dates(["20210301","20210331"])<jupyter_output><empty_output><jupyter_text>Olpe Pick a Kreis with grave differences.<jupyter_code>kreise_gdf = gpd.read_file("/mnt/c/Users/maita.schade/Nextcloud/Documents/Work/Gap_Map/raw/geo/vg250-ew_12-31.utm32s.shape.ebenen/vg250-ew_ebenen_1231/VG250_KRS.shp"
                          ).to_crs("epsg:4326")
olpe_gdf = kreise_gdf[kreise_gdf.GEN=="Olpe"]
# f20_mar_olpe = gtfs_kit_scissors.cut_geom(f20_mar, olpe_gdf, validate=False)
f20_mar_olpe = f20_mar.restrict_to_area(olpe_gdf)
# f21_mar_olpe = gtfs_kit_scissors.cut_geom(f21_mar, olpe_gdf, validate=False)
f21_mar_olpe = f21_mar.restrict_to_area(olpe_gdf)
len(f20_mar_olpe.routes)
f20_mar_olpe.routes
len(f21_mar_olpe.routes)
f21_mar_olpe.routes
f21_mar_olpe.agency
f20_mar_olpe.agency<jupyter_output><empty_output><jupyter_text>Es sieht so aus, als ob hier einfach ein Haufen Agenturen fehlten in 2020--wobei eine auch weggefallen ist... Wie sieht es aus mit den Bussen, die es nicht gibt?<jupyter_code>f20_mar.routes[f20_mar.routes.agency_id=='166']<jupyter_output><empty_output><jupyter_text>Die Schlimmsten...  Anhalt-Bitterfeld<jupyter_code>anh_bitt_gdf = kreise_gdf[kreise_gdf.GEN=="Anhalt-Bitterfeld"]
# f20_mar_olpe = gtfs_kit_scissors.cut_geom(f20_mar, olpe_gdf, validate=False)
f20_mar_ab = f20_mar.restrict_to_area(anh_bitt_gdf)
# f21_mar_olpe = gtfs_kit_scissors.cut_geom(f21_mar, olpe_gdf, validate=False)
f21_mar_ab = f21_mar.restrict_to_area(anh_bitt_gdf)
len(f20_mar_ab.routes)
f20_mar_ab.routes.agency_id.value_counts()
len(f21_mar_ab.routes)
f21_mar_ab.routes.agency_id.value_counts()
f20_mar_ab.agency
f21_mar_ab.agency<jupyter_output><empty_output><jupyter_text>Berlin<jupyter_code>berlin_gdf = kreise_gdf[kreise_gdf.GEN=="Berlin"]
f20_mar_berlin = f20_mar.restrict_to_area(berlin_gdf)
f21_mar_berlin = f21_mar.restrict_to_area(berlin_gdf)
len(f20_mar_berlin.routes)
f20_mar_berlin.routes
len(f21_mar_berlin.routes)
f21_mar_berlin.routes
f20_mar_berlin.agency
f21_mar_berlin.agency<jupyter_output><empty_output><jupyter_text>This doesn't tell us much, yet. How about trip stats for first week in March?<jupyter_code>firstweek21 = ["2021030"+str(n) for n in range(1,8)]
firstweek20 = ["2020030"+str(n) for n in range(2,9)]
gk.compute_feed_stats(f20_mar_berlin, gk.compute_trip_stats(f20_mar_berlin), firstweek20)
gk.compute_feed_stats(f21_mar_berlin, gk.compute_trip_stats(f21_mar_berlin), firstweek21)
gk.compute_stop_stats(f20_mar_berlin, firstweek20)
gk.compute_stop_stats(f21_mar_berlin, firstweek21)<jupyter_output><empty_output><jupyter_text>Wittenberg Schauen wir uns mal einen weiteren Kreis an. Wittenberg.<jupyter_code>wittenb_gdf = kreise_gdf[kreise_gdf.GEN=="Wittenberg"]
wittenb_gdf
f20_mar_wittenb = gtfs_kit_scissors.cut_geom(f20_mar, wittenb_gdf, validate=False)
f21_mar_wittenb = gtfs_kit_scissors.cut_geom(f21_mar, wittenb_gdf, validate=False)
f20_mar_wittenb.routes
f21_mar_wittenb.routes
f20_mar_wittenb.agency
f21_mar_wittenb.agency<jupyter_output><empty_output><jupyter_text>Hier scheint die "Vetter GmbH" einfach weggefallen zu sein... Die sind wohl schon länger umstritten: https://www.wittenbergersonntag.de/artikel/826  Leer<jupyter_code>keyword = "Leer"
from IPython.display import display
leer_gdf = kreise_gdf[kreise_gdf.GEN==keyword]

f20_mar_leer = gtfs_kit_scissors.cut_geom(f20_mar, leer_gdf, validate=False)

f21_mar_leer = gtfs_kit_scissors.cut_geom(f21_mar, leer_gdf, validate=False)

display(f20_mar_leer.routes)

display(f21_mar_leer.routes)

display(f20_mar_leer.agency)

display(f21_mar_leer.agency)
f20_mar_leer.stops
f21_mar_leer.stops
f21_mar_leer.calendar
f20_mar_leer.calendar
def uniqueGdf(gdf):
    uni_gdf = gdf.iloc[[0]]
    for i, r in gdf.iterrows():
        if not (any([p.equals(r.geometry) for p in uni_gdf.geometry])):
            uni_gdf = uni_gdf.append(r) 
    return uni_gdf
point_counts_21 = gpd.sjoin(uni_gdf[["stop_id","geometry"]], stops_harz_21, op='intersects'
         ).groupby("stop_id_left"
                  ).agg({"stop_id_right":"count",
                         "geometry":"first", 
                         "stop_name":"first"
                        })
point_counts_21
display(point_counts_21.stop_id_right.value_counts())
print(point_counts_21.stop_id_right.sum())
point_counts_21[point_counts_21.stop_id_right>2]
stops_harz_21[stops_harz_21.stop_id.isin(point_counts_21[point_counts_21.stop_id_right>2].index)]
point_counts_20 = gpd.sjoin(uniqueGdf(stops_harz_20)[["stop_id","geometry"]],
                            stops_harz_20, 
                            op='intersects'
         ).groupby("stop_id_left"
                  ).agg({"stop_id_right":"count",
                         "geometry":"first"
                        })
display(point_counts_20.stop_id_right.value_counts())
print(point_counts_20.stop_id_right.sum())
point<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11547127300037552, 'fraction_numerical': 0.05970709725873075, 'mean_word_length': 6.287277701778386, 'pattern_counts': {'":': 5, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '652166', 'license': 'MIT', 'n_tokens_mistral': 2487, 'n_tokens_neox': 2290, 'n_words': 248, 'path': 'scrap/gtfs_comparison_march.ipynb', 'repo_name': 'maitagorri/gapmap', 'size': '5326'}