Skip to content

Leading Zeros Are Removed After dtypes Set to "string" #642

Open
@chunkangwong

Description

@chunkangwong

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions