Datasets:
File size: 915 Bytes
5156398 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from pathlib import Path
import pandas as pd
FILE_BASE = "yt_seg"
PARTITION_BASE = FILE_BASE + ".{}"
def _read_segmentation_json(data_file):
data_df = pd.read_json(data_file, orient='records', lines=True)
data_df["targets"] = data_df["targets"].str.lstrip("|=") # to enforce string type, in order to avoid truncation of leading zeros
return data_df
def get_data():
data_file = Path("data", f'{FILE_BASE}.json')
return _read_segmentation_json(data_file)
def get_partition(partition):
data_file = Path("data", "partitions", PARTITION_BASE.format(partition) + '.json')
return _read_segmentation_json(data_file)
FILE_BASE_TITLE = "yt_seg_titles.{}"
def get_title_partition(partition):
data_file = Path("data", "partitions", FILE_BASE_TITLE.format(partition) + '.json')
data_df = pd.read_json(data_file, orient='records', lines=True)
return data_df |