danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

loc with one row cause error

Open Requiemu opened this issue 2 years ago • 1 comments

let data = { "Name": ["Apples", "Mango", "Banana", "Pear"],
            "Count": [21, 5, 30, 10],
            "Price": [200, 300, 40, 250] }

let df = new dfd.DataFrame(data, {index: ["a", "b", "c", "d"]})
df.print()
let sub_df = df.loc({rows: ["a"]})
sub_df.print()

In browser, this will cause error:

Uncaught Error: IndexError: Specified index (a) not found at t._loc (startup:4:47) at t.loc (startup:4:47) at pen.js?key=pen.js-8a2f7821-cb23-e0d2-07e7-2b53e94c09e0:7:17

This will only happen when the rows have exactly one element, if it's let sub_df = df.loc({rows: ["a", "b"]}), then it is normal.

Requiemu avatar Sep 01 '23 08:09 Requiemu