<jupyter_start><jupyter_text>csv to json<jupyter_code>import pandas as pd
goog = pd.read_csv('goog.csv')
goog.head()
# orient columns (default), index, records, split
goog.to_json(orient='split')
import json
json.loads(goog.to_json(orient='records'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14642857142857144, 'fraction_numerical': 0.0, 'mean_word_length': 9.407407407407407, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '643695', 'license': 'MIT', 'n_tokens_mistral': 108, 'n_tokens_neox': 102, 'n_words': 19, 'path': 'Section 3/3.5-csv_to_json.ipynb', 'repo_name': 'PacktPublishing/The-Modern-Python-Challenge-v-', 'size': '280'}