Datasets:
Download source/tests/solvers/cmp_channels.py from Syndicate604/skills-desk: direct link, hf CLI and curl.
- Browser
- Download file 579 Bytes
-
https://huggingface.co/datasets/Syndicate604/skills-desk/resolve/main/source/tests/solvers/cmp_channels.py
- Command line
-
hf download hf://datasets/Syndicate604/skills-desk/source/tests/solvers/cmp_channels.py
-
curl -L -o cmp_channels.py https://huggingface.co/datasets/Syndicate604/skills-desk/resolve/main/source/tests/solvers/cmp_channels.py
579 Bytes
| import csv | |
| def secs(d): | |
| t = 0 | |
| for p in d.split(":"): | |
| t = t * 60 + int(p) | |
| return t | |
| agg = {} | |
| for r in csv.DictReader(open("videos.csv")): | |
| a = agg.setdefault(r["channel"], [0, 0.0, 0.0]) | |
| s = secs(r["duration"]) | |
| a[0] += s | |
| if r["views"].strip(): | |
| v = float(r["views"].replace(",", "")) | |
| a[1] += s / 60 * v | |
| a[2] += v | |
| w = csv.writer(open("channel_stats.csv", "w", newline="")) | |
| w.writerow(["channel", "total_hours", "weighted_minutes"]) | |
| for ch, (s, wv, v) in agg.items(): | |
| w.writerow([ch, f"{s / 3600:.2f}", f"{wv / v:.2f}"]) | |