Skip to content

Values mapped to incorrect columns #556

Open
@febilyt

Description

@febilyt

Describe the bug
When creating a dataframe from an object array, if the keys of different objects are not in the same order, the values will be mapped to an incorrect column.

To Reproduce
Sample code

const dfd = require("danfojs-node");

let data = [
  {
      Id: 1,
      Name: 'Apple'
  },
  {
      Name: 'Orange',
      Id: 2
  },
];
let df = new dfd.DataFrame(data);
df.print();

Output:

╔════════════╤═══════════════════╤═══════════════════╗
║            │ Id                │ Name              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 1                 │ Apple             ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ Orange            │ 2                 ║
╚════════════╧═══════════════════╧═══════════════════╝

Expected behavior
Value should be mapped to correct column depending on the object key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions