Created
January 30, 2025 08:09
-
-
Save do-me/dc8877049c2c074df3c7d8e707adf138 to your computer and use it in GitHub Desktop.
Trim embedding decimals from pandas
This file contains hidden or 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 pandas as pd | |
import json | |
import gzip | |
# Load data | |
df = pd.read_json("your_file.json.gz") | |
# Round embeddings to 4 decimal places | |
df["embeddings"] = df["embeddings"].apply(lambda emb: [round(e, 4) for e in emb]) | |
# Save to a gzipped JSON file | |
with gzip.open("your_file__4_dec.json.gz", "wt", encoding="utf-8") as f: | |
json.dump(df.to_dict(orient="records"), f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment