Skip to content

Changig column classes is slow. #2138

@juanpide

Description

@juanpide

I'm working with large datasets (around 4GB), mixing dates, numbers and factors.

And I want to perform operations such as changing all column classes to character.

mydata[, names(mydata) := lapply(.SD, as.character)]

But it's quite slow.

If you just had the data on the disk and reload it with
my <- fread("mydata.csv", stringsAsFactors=F, colClasses=list(character=1:3775))

it's much faster.

Is there alternative to the first method?
Or maybe it could be improved in some way.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions