Visitar URL original
`sf.apply` not working with dates · Issue #574 · javascriptdata/danfojs · GitHub
Skip to content

sf.apply not working with dates #574

Description

@Decezaris

Using danfo-node, with node 16...

timestamp is a column created from new Date() instance

const sfHourly = df.column('timestamp').apply((date) => {
    const dt = new Date(date);
    dt.setMinutes(0);
    
    return dt;
});

This code throws the following message TypeError: arr.slice is not a function

Activity

  1. changed the title [-]sf.apply not working with dates[/-] [+]`sf.apply` not working with dates[/+] on May 6, 2023
  2. junduck commented on Nov 12, 2025

    @junduck

    I can confirm this bug comes from is1DArray utility that it only checks if typeof arr as:

    if (
                typeof arr[0] == "number" ||
                typeof arr[0] == "string" ||
                typeof arr[0] == "boolean" ||
                arr[0] === null
            ) {
                return true;
            } else {
                return false;
            }

    since datetime is an object, so the implementatio wrongly treats array of datetime as 2d Array.

  3. added a commit that references this issue on Nov 12, 2025
    f622dcf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions