Skip to main content

Function: idColumnsToStrings()

idColumnsToStrings<R>(rows): R[]

Defined in: src/core/int64.ts:158

The id rule over a parser's or producer's rows, in place: every id column of integers becomes decimal strings (idsToStrings). A JSON integer is an Int64 in sdv-py (an id column with nulls is Float64 there, a pandas artifact); either way it is a string here.

Type Parameters​

R​

R extends Record<string, unknown>

Parameters​

rows​

R[]

Row objects; mutated in place. Id columns are every key of any row for which isIdColumn is true.

Returns​

R[]

The same rows array (for chaining), not a copy.

Remarks​

Non-id columns are untouched, so a non-id integer past 2^53 stays whatever the reader produced (see warnBigint). A "not-integers" id column is left as read silently here; surfaces emit notIntegerIdWarning themselves.

Example​

import { idColumnsToStrings } from "./int64.js";
idColumnsToStrings([{ team_id: 5, score: 3, name: "x" }, { team_id: 6, score: 4, name: "y" }]);
// [{ team_id: "5", score: 3, name: "x" }, { team_id: "6", score: 4, name: "y" }]