Quellcode durchsuchen

analyser: calculate mean time for x markers and rate the result

Bernadette Elena Hammerle vor 3 Jahren
Ursprung
Commit
45341f213a
1 geänderte Dateien mit 23 neuen und 0 gelöschten Zeilen
  1. 23 0
      src/database/dbAnalyser.py

+ 23 - 0
src/database/dbAnalyser.py

@@ -80,7 +80,30 @@ def smallValues(df):
     mapboxTypes(df, "mapboxSmall.png")
 
 
+def avgPerMarkerNo(df, markerNo):
+    print(f"\naverage time for {markerNo} markers")
+    print("number of measurements")
+    df = df.loc[df["markers"] == markerNo]
+    resDf = pd.DataFrame(columns=["id", "timeMean", "rating"])
+    for mapId, mapDf in df.groupby(["id"]):
+        if mapId != "mapbox":
+            print(mapId, mapDf.shape[0])
+            resDf = resDf.append({"id": mapId, "timeMean": mapDf["time"].mean()}, ignore_index=True)
+        else:
+            for markerType, typeDf in mapDf.groupby(["type"]):
+                print(markerType, typeDf.shape[0])
+                resDf = resDf.append({"id": "mapbox_" + markerType, "timeMean": typeDf["time"].mean()}, ignore_index=True)
+
+    resDf = resDf.assign(rating=lambda x: (round(4-((4-0)/(max(resDf["timeMean"])-min(resDf["timeMean"]))*(x["timeMean"]-max(resDf["timeMean"]))+4))))
+    print(resDf)
+
+
+
 df = readFile()
+print(df.columns)
+avgPerMarkerNo(df, 100)
+avgPerMarkerNo(df, 1000)
+avgPerMarkerNo(df, 10000)
 timeMaps(df)
 mapboxTypes(df)
 smallValues(df)