{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "a6d96660", "metadata": { "metadata": {} }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "workding dir: /Users/inflaton/code/emtech/gpt/llm-qa-bench\n" ] } ], "source": [ "import os\n", "import sys\n", "from pathlib import Path\n", "\n", "workding_dir = str(Path.cwd().parent)\n", "os.chdir(workding_dir)\n", "sys.path.append(workding_dir)\n", "print(\"workding dir:\", workding_dir)" ] }, { "cell_type": "code", "execution_count": 2, "id": "b72bf3f9", "metadata": { "metadata": {} }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/inflaton/anaconda3/envs/llm-qa-bench/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "data": { "text/plain": [ "Dataset({\n", " features: ['answers', 'passages', 'query', 'query_id', 'query_type', 'wellFormedAnswers'],\n", " num_rows: 500\n", "})" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from datasets import load_from_disk\n", "\n", "new_ds = load_from_disk(\"./Llama-2-eval/data/datasets/ms_macro/\")\n", "new_ds" ] }, { "cell_type": "code", "execution_count": 3, "id": "051bd771", "metadata": { "metadata": {} }, "outputs": [ { "data": { "text/plain": [ "({'NUMERIC': 100,\n", " 'DESCRIPTION': 100,\n", " 'ENTITY': 100,\n", " 'PERSON': 100,\n", " 'LOCATION': 100},\n", " {'NUMERIC': 179,\n", " 'DESCRIPTION': 215,\n", " 'ENTITY': 443,\n", " 'LOCATION': 461,\n", " 'PERSON': 499})" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "counts = {}\n", "indices = {}\n", "size = 100\n", "for i in range(new_ds.num_rows):\n", " row = new_ds[i]\n", " query_type = row[\"query_type\"]\n", " if query_type in counts:\n", " counts[query_type] += 1\n", " else:\n", " counts[query_type] = 1\n", " if counts[query_type] == size:\n", " indices[query_type] = i\n", "counts, indices" ] }, { "cell_type": "code", "execution_count": 4, "id": "db48dcc4", "metadata": { "metadata": {} }, "outputs": [], "source": [ "df = new_ds.to_pandas()" ] }, { "cell_type": "code", "execution_count": 5, "id": "a39dea83", "metadata": { "metadata": {} }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
answerspassagesqueryquery_idquery_typewellFormedAnswers
0[2,662]{'is_selected': [0, 0, 0, 1, 0, 0, 0, 0], 'pas...albany mn population15177NUMERIC[The population of Albany, Minnesota is 2,662. ]
1[The Volcano forecast for Apr 12 is 52 degrees...{'is_selected': [1, 0, 1, 0, 0, 0, 0, 1, 0, 0]...current weather in volcano, ca114414DESCRIPTION[The Volcano forecast for Apr 12 is 52 degrees...
2[Hippocrates]{'is_selected': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]...____________________ is considered the father ...9083DESCRIPTION[Hippocrates is considered the father of moder...
3[120 days from the date of the Note.]{'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]...how many days is an appraisal good for a fanni...281439NUMERIC[An appraisal is good for 120 days from the da...
4[From $26,000 to $39,000 a year]{'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]...average pharmacy tech salary40287NUMERIC[The average salary for a pharmacy technician ...
\n", "
" ], "text/plain": [ " answers \\\n", "0 [2,662] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates] \n", "3 [120 days from the date of the Note.] \n", "4 [From $26,000 to $39,000 a year] \n", "\n", " passages \\\n", "0 {'is_selected': [0, 0, 0, 1, 0, 0, 0, 0], 'pas... \n", "1 {'is_selected': [1, 0, 1, 0, 0, 0, 0, 1, 0, 0]... \n", "2 {'is_selected': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]... \n", "3 {'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]... \n", "4 {'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]... \n", "\n", " query query_id query_type \\\n", "0 albany mn population 15177 NUMERIC \n", "1 current weather in volcano, ca 114414 DESCRIPTION \n", "2 ____________________ is considered the father ... 9083 DESCRIPTION \n", "3 how many days is an appraisal good for a fanni... 281439 NUMERIC \n", "4 average pharmacy tech salary 40287 NUMERIC \n", "\n", " wellFormedAnswers \n", "0 [The population of Albany, Minnesota is 2,662. ] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates is considered the father of moder... \n", "3 [An appraisal is good for 120 days from the da... \n", "4 [The average salary for a pharmacy technician ... " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": 6, "id": "7f0d2ca1", "metadata": { "metadata": {} }, "outputs": [], "source": [ "df.rename(columns={\"query\": \"question\", \"query_id\": \"id\"}, inplace=True)" ] }, { "cell_type": "code", "execution_count": 7, "id": "e1cde4c1", "metadata": { "metadata": {} }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
answerspassagesquestionidquery_typewellFormedAnswers
0[2,662]{'is_selected': [0, 0, 0, 1, 0, 0, 0, 0], 'pas...albany mn population15177NUMERIC[The population of Albany, Minnesota is 2,662. ]
1[The Volcano forecast for Apr 12 is 52 degrees...{'is_selected': [1, 0, 1, 0, 0, 0, 0, 1, 0, 0]...current weather in volcano, ca114414DESCRIPTION[The Volcano forecast for Apr 12 is 52 degrees...
2[Hippocrates]{'is_selected': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]...____________________ is considered the father ...9083DESCRIPTION[Hippocrates is considered the father of moder...
3[120 days from the date of the Note.]{'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]...how many days is an appraisal good for a fanni...281439NUMERIC[An appraisal is good for 120 days from the da...
4[From $26,000 to $39,000 a year]{'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]...average pharmacy tech salary40287NUMERIC[The average salary for a pharmacy technician ...
\n", "
" ], "text/plain": [ " answers \\\n", "0 [2,662] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates] \n", "3 [120 days from the date of the Note.] \n", "4 [From $26,000 to $39,000 a year] \n", "\n", " passages \\\n", "0 {'is_selected': [0, 0, 0, 1, 0, 0, 0, 0], 'pas... \n", "1 {'is_selected': [1, 0, 1, 0, 0, 0, 0, 1, 0, 0]... \n", "2 {'is_selected': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]... \n", "3 {'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]... \n", "4 {'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]... \n", "\n", " question id query_type \\\n", "0 albany mn population 15177 NUMERIC \n", "1 current weather in volcano, ca 114414 DESCRIPTION \n", "2 ____________________ is considered the father ... 9083 DESCRIPTION \n", "3 how many days is an appraisal good for a fanni... 281439 NUMERIC \n", "4 average pharmacy tech salary 40287 NUMERIC \n", "\n", " wellFormedAnswers \n", "0 [The population of Albany, Minnesota is 2,662. ] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates is considered the father of moder... \n", "3 [An appraisal is good for 120 days from the da... \n", "4 [The average salary for a pharmacy technician ... " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": 8, "id": "89494c3d", "metadata": { "metadata": {} }, "outputs": [], "source": [ "import numpy as np\n", "\n", "\n", "def generate_context(row, debug=False):\n", " passages = row[\"passages\"]\n", " if debug:\n", " print(\"question:\", row[\"question\"])\n", " print(passages)\n", "\n", " passage_text = passages[\"passage_text\"]\n", " context = \"\\n\\n\".join(passage_text)\n", "\n", " return context" ] }, { "cell_type": "code", "execution_count": 9, "id": "0dc959f6", "metadata": { "metadata": {} }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "question: albany mn population\n", "{'is_selected': array([0, 0, 0, 1, 0, 0, 0, 0], dtype=int32), 'passage_text': array(['City of Albany, MN Zip Codes. City of Albany, MN Demographic Information. * Demographic data is based on information taken from the 2000 Census. City of Albany, MN covers 1 Area Code. City of Albany, MN covers 1 Zip Code. 15 Cities within 15 Miles of the City of Albany, MN.',\n", " 'Place of birth for U.S.-born residents: 70% of the 56307 zip code residents lived in the same house 5 years ago. Out of people who lived in different houses, 71% lived in this county. Out of people who lived in different counties, 50% lived in Minnesota. 92% of the 56307 zip code residents lived in the same house 1 year ago.',\n", " 'For the unincorporated community in southeast Minnesota named West Albany, see West Albany, Minnesota. Albany is a city in Stearns County, Minnesota, United States. The population was 2,561 at the 2010 census. It is part of the St. Cloud Metropolitan Statistical Area.',\n", " 'Albany, Minnesota, as per 2017 US Census estimate, has a community population of 2,662 people. Albany is located in Stearns County, 20 miles west of St. Cloud and 80 miles northwest of Minneapolis/St. Paul on Interstate 94 (I-94). Albany has direct access to State Highway 238, which originates in Albany.',\n", " 'Sponsored Topics. Albany is a city in Stearns County, Minnesota, United States. The population was 2,561 at the 2010 census. It is part of the St. Cloud Metropolitan Statistical Area.',\n", " 'Recent posts about Albany, Minnesota on our local forum with over 2,000,000 registered users. Albany is mentioned 87 times on our forum: Latest news from Albany, MN collected exclusively by city-data.com from local newspapers, TV, and radio stations. Ancestries: German (55.6%), Irish (10.0%), Polish (5.9%), Norwegian (5.4%), Swedish (2.8%), United States (2.6%).',\n", " \"For population 25 years and over in 56307: 1 High school or higher: 87.4%. 2 Bachelor's degree or higher: 15.4%. 3 Graduate or professional degree: 3.3 4 %. Unemployed: 3. 5 2%. Mean travel time to work (commute): 23.6 minutes.\",\n", " \"For population 25 years and over in Albany: 1 High school or higher: 86.7%. 2 Bachelor's degree or higher: 15.4%. 3 Graduate or professional degree: 4.4 4 %. Unemployed: 4. 5 3%. Mean travel time to work (commute): 23.0 minutes.\"],\n", " dtype=object), 'url': array(['http://zipcode.org/city/MN/ALBANY',\n", " 'http://www.city-data.com/zips/56307.html',\n", " 'https://en.wikipedia.org/wiki/Albany,_Minnesota',\n", " 'http://ci.albany.mn.us/index.asp?SEC=A8341FEC-6B8C-47D2-926B-75A89ED4C539&Type=B_BASIC',\n", " 'https://www.mapquest.com/us/mn/albany-282023394',\n", " 'http://www.city-data.com/city/Albany-Minnesota.html',\n", " 'http://www.city-data.com/zips/56307.html',\n", " 'http://www.city-data.com/city/Albany-Minnesota.html'],\n", " dtype=object)}\n", "City of Albany, MN Zip Codes. City of Albany, MN Demographic Information. * Demographic data is based on information taken from the 2000 Census. City of Albany, MN covers 1 Area Code. City of Albany, MN covers 1 Zip Code. 15 Cities within 15 Miles of the City of Albany, MN.\n", "\n", "Place of birth for U.S.-born residents: 70% of the 56307 zip code residents lived in the same house 5 years ago. Out of people who lived in different houses, 71% lived in this county. Out of people who lived in different counties, 50% lived in Minnesota. 92% of the 56307 zip code residents lived in the same house 1 year ago.\n", "\n", "For the unincorporated community in southeast Minnesota named West Albany, see West Albany, Minnesota. Albany is a city in Stearns County, Minnesota, United States. The population was 2,561 at the 2010 census. It is part of the St. Cloud Metropolitan Statistical Area.\n", "\n", "Albany, Minnesota, as per 2017 US Census estimate, has a community population of 2,662 people. Albany is located in Stearns County, 20 miles west of St. Cloud and 80 miles northwest of Minneapolis/St. Paul on Interstate 94 (I-94). Albany has direct access to State Highway 238, which originates in Albany.\n", "\n", "Sponsored Topics. Albany is a city in Stearns County, Minnesota, United States. The population was 2,561 at the 2010 census. It is part of the St. Cloud Metropolitan Statistical Area.\n", "\n", "Recent posts about Albany, Minnesota on our local forum with over 2,000,000 registered users. Albany is mentioned 87 times on our forum: Latest news from Albany, MN collected exclusively by city-data.com from local newspapers, TV, and radio stations. Ancestries: German (55.6%), Irish (10.0%), Polish (5.9%), Norwegian (5.4%), Swedish (2.8%), United States (2.6%).\n", "\n", "For population 25 years and over in 56307: 1 High school or higher: 87.4%. 2 Bachelor's degree or higher: 15.4%. 3 Graduate or professional degree: 3.3 4 %. Unemployed: 3. 5 2%. Mean travel time to work (commute): 23.6 minutes.\n", "\n", "For population 25 years and over in Albany: 1 High school or higher: 86.7%. 2 Bachelor's degree or higher: 15.4%. 3 Graduate or professional degree: 4.4 4 %. Unemployed: 4. 5 3%. Mean travel time to work (commute): 23.0 minutes.\n", "CPU times: user 255 µs, sys: 41 µs, total: 296 µs\n", "Wall time: 294 µs\n" ] } ], "source": [ "%%time\n", "context = generate_context(df.iloc[0], debug=True)\n", "print(context)" ] }, { "cell_type": "code", "execution_count": 10, "id": "d887d92e", "metadata": { "metadata": {} }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 500/500 [00:00<00:00, 213125.20it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 3.19 ms, sys: 1.47 ms, total: 4.67 ms\n", "Wall time: 4.01 ms\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "%%time\n", "from tqdm import tqdm\n", "\n", "tqdm.pandas()\n", "\n", "df[\"context\"] = df.progress_apply(\n", " generate_context, axis=1\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "id": "dfdf1d5a", "metadata": { "metadata": {} }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
answerspassagesquestionidquery_typewellFormedAnswerscontext
0[2,662]{'is_selected': [0, 0, 0, 1, 0, 0, 0, 0], 'pas...albany mn population15177NUMERIC[The population of Albany, Minnesota is 2,662. ]City of Albany, MN Zip Codes. City of Albany, ...
1[The Volcano forecast for Apr 12 is 52 degrees...{'is_selected': [1, 0, 1, 0, 0, 0, 0, 1, 0, 0]...current weather in volcano, ca114414DESCRIPTION[The Volcano forecast for Apr 12 is 52 degrees...Volcano 10 Day Weather. Sunday:The Volcano for...
2[Hippocrates]{'is_selected': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]...____________________ is considered the father ...9083DESCRIPTION[Hippocrates is considered the father of moder...Hippocrates is widely considered to be the Fat...
3[120 days from the date of the Note.]{'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]...how many days is an appraisal good for a fanni...281439NUMERIC[An appraisal is good for 120 days from the da...New and Updated Underwriting and Eligibility P...
4[From $26,000 to $39,000 a year]{'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]...average pharmacy tech salary40287NUMERIC[The average salary for a pharmacy technician ...If you are interested in becoming a pharmacy t...
\n", "
" ], "text/plain": [ " answers \\\n", "0 [2,662] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates] \n", "3 [120 days from the date of the Note.] \n", "4 [From $26,000 to $39,000 a year] \n", "\n", " passages \\\n", "0 {'is_selected': [0, 0, 0, 1, 0, 0, 0, 0], 'pas... \n", "1 {'is_selected': [1, 0, 1, 0, 0, 0, 0, 1, 0, 0]... \n", "2 {'is_selected': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]... \n", "3 {'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]... \n", "4 {'is_selected': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]... \n", "\n", " question id query_type \\\n", "0 albany mn population 15177 NUMERIC \n", "1 current weather in volcano, ca 114414 DESCRIPTION \n", "2 ____________________ is considered the father ... 9083 DESCRIPTION \n", "3 how many days is an appraisal good for a fanni... 281439 NUMERIC \n", "4 average pharmacy tech salary 40287 NUMERIC \n", "\n", " wellFormedAnswers \\\n", "0 [The population of Albany, Minnesota is 2,662. ] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates is considered the father of moder... \n", "3 [An appraisal is good for 120 days from the da... \n", "4 [The average salary for a pharmacy technician ... \n", "\n", " context \n", "0 City of Albany, MN Zip Codes. City of Albany, ... \n", "1 Volcano 10 Day Weather. Sunday:The Volcano for... \n", "2 Hippocrates is widely considered to be the Fat... \n", "3 New and Updated Underwriting and Eligibility P... \n", "4 If you are interested in becoming a pharmacy t... " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": 14, "id": "8a1050b9", "metadata": { "metadata": {} }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idquestionanswerswellFormedAnswerscontextquery_type
015177albany mn population[2,662][The population of Albany, Minnesota is 2,662. ]City of Albany, MN Zip Codes. City of Albany, ...NUMERIC
1114414current weather in volcano, ca[The Volcano forecast for Apr 12 is 52 degrees...[The Volcano forecast for Apr 12 is 52 degrees...Volcano 10 Day Weather. Sunday:The Volcano for...DESCRIPTION
29083____________________ is considered the father ...[Hippocrates][Hippocrates is considered the father of moder...Hippocrates is widely considered to be the Fat...DESCRIPTION
3281439how many days is an appraisal good for a fanni...[120 days from the date of the Note.][An appraisal is good for 120 days from the da...New and Updated Underwriting and Eligibility P...NUMERIC
440287average pharmacy tech salary[From $26,000 to $39,000 a year][The average salary for a pharmacy technician ...If you are interested in becoming a pharmacy t...NUMERIC
\n", "
" ], "text/plain": [ " id question \\\n", "0 15177 albany mn population \n", "1 114414 current weather in volcano, ca \n", "2 9083 ____________________ is considered the father ... \n", "3 281439 how many days is an appraisal good for a fanni... \n", "4 40287 average pharmacy tech salary \n", "\n", " answers \\\n", "0 [2,662] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates] \n", "3 [120 days from the date of the Note.] \n", "4 [From $26,000 to $39,000 a year] \n", "\n", " wellFormedAnswers \\\n", "0 [The population of Albany, Minnesota is 2,662. ] \n", "1 [The Volcano forecast for Apr 12 is 52 degrees... \n", "2 [Hippocrates is considered the father of moder... \n", "3 [An appraisal is good for 120 days from the da... \n", "4 [The average salary for a pharmacy technician ... \n", "\n", " context query_type \n", "0 City of Albany, MN Zip Codes. City of Albany, ... NUMERIC \n", "1 Volcano 10 Day Weather. Sunday:The Volcano for... DESCRIPTION \n", "2 Hippocrates is widely considered to be the Fat... DESCRIPTION \n", "3 New and Updated Underwriting and Eligibility P... NUMERIC \n", "4 If you are interested in becoming a pharmacy t... NUMERIC " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# reordering columns\n", "df = df[[\"id\", \"question\", \"answers\", \"wellFormedAnswers\", \"context\", \"query_type\"]]\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 15, "id": "24a818ba", "metadata": { "metadata": {} }, "outputs": [], "source": [ "# save df to json with indent=4\n", "df.to_json(\n", " \"./data/datasets/ms_macro.json\", orient=\"records\", indent=4\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }