import os import pandas as pd import time import json import random import dateutil.parser #read parquet file df = pd.read_parquet("/mnt/data/danbooru-wiki-2024/data/train-00000-of-00001.parquet") print(df.columns) print(df.head()) #print first 5 rows print(df.head(5)) #to_dict df_dict = df.to_dict(orient='records') print(df_dict[0]) # "{'id': 115416, 'created_at': '2020-08-08T19:16:56.966+09:00', 'updated_at': '2023-01-03T01:14:39.307+09:00', 'title': 'veemusic', 'other_names': array([], dtype=object), 'body': '[[Virtual YouTuber]] agency and music label launched in November 2018 by [[Virtual Gorilla]], who acts as its virtual president. Its members include individual and group-oriented VTubers.\r\n\r\nh4. Members\r\n\r\n* [[Virtual Gorilla]]\r\n* [[Hosaki Menma]] (left February 2020)\r\n* [[Inui Shin\'ichirou]]\r\n* [[Chikuwa (vtuber)|]] (retired)\r\n\r\nh4. External links\r\n\r\n* "Offical Website":http://veemusic.jp/\r\n* "YouTube":https://www.youtube.com/@veemusic3056\r\n* "Twitter":https://twitter.com/VEEM_Official', 'is_locked': False, 'is_deleted': False, 'category': 'copyright', 'tag': 'veemusic'} # (naifu) root@iv-ydj8v22akgqbxys13oit:/mnt/data# " # arrat to list for i in range(len(df_dict)): df_dict[i]['other_names'] = df_dict[i]['other_names'].tolist() # print(df_dict[0]) # save to json with open('/mnt/data/danbooru-wiki-2024/data/train-00000-of-00001.json', 'w') as f: json.dump(df_dict, f)