Skip to content

Concat behaviour differs significantly from pandas (column order dependent) #641

Description

@bml1g12

Describe the bug

DataFrame creation is column order dependent, unlike Pandas

Definition of an Object from ECMAScript Third Edition (pdf):

4.3.3 Object
An object is a member of the type Object. It is an unordered collection of properties each of which contains a primitive value, object, or function. A function stored in a property of an object is called a method.

To Reproduce

Danfo.js v1.1.2

const json_data_3d = [
  { campaignId: "toyota", agentId: "bob", metricValue: 1, metricId: "callCount" },
  { campaignId: "toyota", agentId: "jim", metricValue: 2, metricId: "callCount" },
  { campaignId: "sony", agentId: "ben", metricValue: 3, metricId: "callCount" },
  { campaignId: "sony", agentId: "karl", metricId: "callCount", metricValue: 4,},
];
const dfone = new dfd.DataFrame(json_data_3d);
dfone.print()
╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ campaignId        │ agentId           │ metricValue       │ metricId          ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0          │ toyota            │ bob               │ 1                 │ callCount         ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1          │ toyota            │ jim               │ 2                 │ callCount         ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2          │ sony              │ ben               │ 3                 │ callCount         ║
╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 3          │ sony              │ karl              │ callCount         │ 4                 ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

Expected behavior

import pandas as pd

const json_data_3d = [
  { campaignId: "toyota", agentId: "bob", metricValue: 1, metricId: "callCount" },
  { campaignId: "toyota", agentId: "jim", metricValue: 2, metricId: "callCount" },
  { campaignId: "sony", agentId: "ben", metricValue: 3, metricId: "callCount" },
  { campaignId: "sony", agentId: "karl", metricValue: 4, metricId: "callCount" },
];
const dfone = new dfd.DataFrame(json_data_3d);)
print(dfone)
  campaignId agentId  metricValue   metricId
0     toyota     bob            1  callCount
1     toyota     jim            2  callCount
2       sony     ben            3  callCount
3       sony    karl            4  callCount

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions