Title: Reference data turns CUSIP, CIK and other ID columns into numbers · Issue #146 · databento/databento-python · GitHub
Open Graph Title: Reference data turns CUSIP, CIK and other ID columns into numbers · Issue #146 · databento/databento-python
X Title: Reference data turns CUSIP, CIK and other ID columns into numbers · Issue #146 · databento/databento-python
Description: convert_jsonl_to_df reads reference responses with pd.read_json(TextIOWrapper(reader), lines=True) (parsing.py line 481). read_json defaults to dtype=True, so any identifier column whose values are all digits comes back as int64 (or floa...
Open Graph Description: convert_jsonl_to_df reads reference responses with pd.read_json(TextIOWrapper(reader), lines=True) (parsing.py line 481). read_json defaults to dtype=True, so any identifier column whose values are...
X Description: convert_jsonl_to_df reads reference responses with pd.read_json(TextIOWrapper(reader), lines=True) (parsing.py line 481). read_json defaults to dtype=True, so any identifier column whose values are...
Opengraph URL: https://github.com/databento/databento-python/issues/146
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reference data turns CUSIP, CIK and other ID columns into numbers","articleBody":"`convert_jsonl_to_df` reads reference responses with `pd.read_json(TextIOWrapper(reader), lines=True)` ([parsing.py line 481](https://github.com/databento/databento-python/blob/f6529f1062e0642fe52334d767a72f2a75244398/databento/common/parsing.py#L481)). `read_json` defaults to `dtype=True`, so any identifier column whose values are all digits comes back as int64 (or float64 when there's a null), and leading zeros are lost.\n\nThis reaches `security_master.get_last` and `get_range`, `corporate_actions.get_range` and `adjustment_factors.get_range`.\n\n### Example\n\nWith the repo's own fixture `tests/data/REFERENCE/test_data.security-master.jsonl` (Apple), mocked the same way as `tests/test_reference_security.py`, `client.security_master.get_last(symbols=\"AAPL\")` gives\n\n| field | JSON from the API | DataFrame today |\n|---|---|---|\n| us_code (CUSIP) | `\"037833100\"` | `37833100` (int64) |\n| cik | `\"0000320193\"` | `320193` (int64) |\n| sic | `\"3571\"` | `3571` (int64) |\n| naics | `\"334111\"` | `334111` (int64) |\n\nThe adjustment factors fixture (Microsoft) does the same with us_code `\"594918104\"`, and option_id `\"1\"` in the corporate actions fixture comes back as an int.\n\nCIKs are always zero-padded to 10 digits, so every row with a CIK loses characters. For CUSIPs, SIC and local codes it depends on whether every value in that column of the response is all digits, so the same column can come back as strings in one call and as numbers in another (a Hong Kong local_code like `00005` would become `5`).\n\n### Possible fix\n\nPass the identifier columns to `read_json` as `dtype=object` (symbol, nasdaq_symbol, local_code, local_code_resulting, outturn_local_code, us_code, outturn_us_code, sic, cik, gics, naics, option_id, serial_id), so every other column is read exactly as before. I have it working locally, about 25 lines in 2 files, and the reference and parsing tests (120) and the full suite still pass. One side effect is that listed columns that were already text change dtype from pandas' `str` to `object`. Happy to open a PR if that's useful.\n\nI used Claude Code to find and check this.\n","author":{"url":"https://github.com/JeetuSK0808","@type":"Person","name":"JeetuSK0808"},"datePublished":"2026-11-21T04:43:25Z","url":"https://github.com/databento/databento-python/issues/146"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:47406ab3-a427-0e1a-d6e1-23863ac1bee1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC26:1D68C9:1973AA2:220390F:6B03F3FC |
| html-safe-nonce | dc3fc0f544e8c5e95ab20571107ec13f547ff1fa5816f0eaad881db1e267eb51 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzI2OjFENjhDOToxOTczQUEyOjIyMDM5MEY6NkIwM0YzRkMiLCJ2aXNpdG9yX2lkIjoiNDg0NTM1MTg0NzY1MDkxNTMyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ffa3b87065c32eb3cc9ad16a850f6110767e7a896869cddca84ead722200a14a |
| hovercard-subject-tag | issue:6524549587 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/databento/databento-python/146/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bfe1238d3c15419149f5a17b2d8f4cee1d4c95d04cd1d86805dd4dff772175a3/databento/databento-python/issues/146 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bfe1238d3c15419149f5a17b2d8f4cee1d4c95d04cd1d86805dd4dff772175a3/databento/databento-python/issues/146 |
| og:image:alt | convert_jsonl_to_df reads reference responses with pd.read_json(TextIOWrapper(reader), lines=True) (parsing.py line 481). read_json defaults to dtype=True, so any identifier column whose values are... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JeetuSK0808 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/databento/databento-python git https://github.com/databento/databento-python.git |
| octolytics-dimension-user_id | 64141749 |
| octolytics-dimension-user_login | databento |
| octolytics-dimension-repository_id | 440757282 |
| octolytics-dimension-repository_nwo | databento/databento-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440757282 |
| octolytics-dimension-repository_network_root_nwo | databento/databento-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width