Skip to content

Commit b8892c9

Browse files
committed
Allow Series.append() to use zero
1 parent b77662d commit b8892c9

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/danfojs-base/core/series.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,8 +1855,8 @@ export default class Series extends NDframe implements SeriesInterface {
18551855
): Series | void {
18561856
const { inplace } = { inplace: false, ...options }
18571857

1858-
if (!newValue && typeof newValue !== "boolean") {
1859-
throw Error("Param Error: newValues cannot be null or undefined");
1858+
if (!newValue && typeof newValue !== "boolean" && typeof newValue !== "number") {
1859+
throw Error("Param Error: newValue cannot be null or undefined");
18601860
}
18611861

18621862
if (!index) {

src/danfojs-browser/tests/core/series.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,13 @@ describe("Series Functions", () => {
14911491
sf1.append(sf2, index, { inplace: true });
14921492
assert.deepEqual(sf1.index, [ 0, 1, 2, 3, 4, 5, 6 ]);
14931493
});
1494+
it("Can append a value of zero", function() {
1495+
const data = [ 1, 2, 3, 4, "a", "b", "c" ];
1496+
const sf = new dfd.Series(data);
1497+
const expected_val = [ 1, 2, 3, 4, "a", "b", "c", 0 ];
1498+
sf.append(0, 7, { inplace: true });
1499+
assert.deepEqual(sf.values, expected_val);
1500+
});
14941501
});
14951502

14961503
describe("and", function () {

src/danfojs-node/test/core/series.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,13 @@ describe("Series Functions", () => {
14921492
sf1.append(sf2, index, { inplace: true });
14931493
assert.deepEqual(sf1.index, [0, 1, 2, 3, 4, 5, 6]);
14941494
});
1495+
it("Can append a value of zero", function() {
1496+
const data = [1, 2, 3, 4, "a", "b", "c"];
1497+
const sf = new Series(data);
1498+
const expected_val = [1, 2, 3, 4, "a", "b", "c", 0];
1499+
sf.append(0, 7, { inplace: true });
1500+
assert.deepEqual(sf.values, expected_val);
1501+
})
14951502
});
14961503

14971504
describe("and", function () {

0 commit comments

Comments
 (0)