danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

Leading Zeros Are Removed After dtypes Set to "string"

Open chunkangwong opened this issue 1 year ago • 0 comments

Describe the bug When using readCSV and readExcel, with a CSV file that contains zero-leading numbers, the leading zeros are not preserved even after setting dtypes to string

To Reproduce Steps to reproduce the behavior:

  1. Prepare the following .csv file:

./sample.csv

codes
012345
067890
import { readCSV, toJSON } from "danfojs";

const df = await readCSV("./sample.csv", { 
    frameConfig: {
        dtypes: ["string"],
    },
});
const data = toJSON(df);
console.log(data) // [{ codes: 12345 }, { codes: 67890 }]

Expected behavior Leading-zeros should be retained if dtypes is string

Desktop (please complete the following information):

  • OS: Windos 10
  • Browser Chrome
  • Version 1.1.1

chunkangwong avatar Jun 18 '24 08:06 chunkangwong