Skip to content

groupby casts string column to int #183

Closed
@td7650

Description

@td7650

Describe the bug
Running the example code below results in wrong column type

To Reproduce
Steps to reproduce the behavior:

  1. Open the attached test.html in your browser
  2. or group a string column with numerical values like "2021-01" and count another column
var json_data = [
  { key: "P1", month: "2021-01", storypoints: 3 },
  { key: "P2", month: "2021-02", storypoints: 1 },
  { key: "P3", month: "2021-02", storypoints: 3 },
  { key: "P4", month: "2021-03", storypoints: 2 },
  { key: "P5", month: "2021-04", storypoints: 3 }
];
let df = new dfd.DataFrame(json_data);
df.plot("div1").table()

let grp = df.groupby(["month"]);
let new_df = grp.col(["key"]).count();
new_df.plot("div2").table()

Expected behavior

  1. column "month" in grouped dataframe should show values like "2021-01", "2021-02", ...
  2. instead the whole columns datatype is changed from string to int and it shows multiple entries of "2021", "2021"
  3. the month part after the "-" is cut off

Screenshots
test.zip - zipped test.html
code

ungrouped
grouped

Desktop (please complete the following information):

  • OS: Win 10
  • Browser chrome
  • Version 89.0.4389.128

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