Created
February 15, 2023 09:05
-
-
Save nawarazpokhrel/6f1100a1c22843902a1bb1bbca54f803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
out = {} | |
for b, g in df.groupby("Make"): | |
out[b] = { | |
row["Model"]: { | |
"2021": " ".join(str(row["2021"]).split()), | |
"2020": " ".join(str(row["2020"]).split()), | |
"2019": " ".join(str(row["2019"]).split()), | |
"2018": " ".join(str(row["2018"]).split()), | |
"2017": " ".join(str(row["2017"]).split()), | |
"2016":" ".join(str(row["2016"]).split()), | |
"2015": " ".join(str(row["2015"]).split()), | |
} | |
for _, row in g.iterrows() | |
} | |
with open('/home/navaraj/Documents/new_data.json', 'w') as outfile: | |
json.dump(out, outfile) | |
from pprint import pprint | |
pprint(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment