Created
March 20, 2026 07:05
-
-
Save nikbpetrov/18ba6817d78d3eadbb12b6d376514f09 to your computer and use it in GitHub Desktop.
pd reads null as NaN
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 | |
| jsonl = '{"id": "q1", "date": "2025-01-01", "value": 10}\n{"id": "q1", "date": "2025-01-05", "value": null}' | |
| dfr = pd.read_json(jsonl, lines=True, dtype={"id": str, "date": str}, convert_dates=False) | |
| dfr["date"] = pd.to_datetime(dfr["date"]) | |
| print(f"Jan 5 value: {dfr.iloc[1]['value']!r} (type: {type(dfr.iloc[1]['value']).__name__})") | |
| # Jan 5 value: np.float64(nan) (type: float64) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment