MCPcopy Create free account
hub / github.com/javascriptdata/danfojs / or

Method or

src/danfojs-base/core/series.ts:2066–2106  ·  view source on GitHub ↗

* Returns the logical OR between Series and other. Supports element wise operations and broadcasting. * @param other Series, Scalar, Array of Scalars * @example * ``` * const sf = new Series([true, true, false, false, true]); * const sf2 = new Series([true, false, true, fal

(other: any)

Source from the content-addressed store, hash-verified

2064 *
2065 */
2066 or(other: any): Series {
2067
2068 if (other === undefined) {
2069 throw new Error("Param Error: other cannot be undefined");
2070 }
2071 const newValues: ArrayType1D = [];
2072
2073 if (other instanceof Series) {
2074 if (this.dtypes[0] !== other.dtypes[0]) {
2075 throw new Error("Param Error: Series must be of same dtype");
2076 }
2077
2078 if (this.shape[0] !== other.shape[0]) {
2079 throw new Error("Param Error: Series must be of same shape");
2080 }
2081
2082 this.values.forEach((val, i) => {
2083 newValues.push(Boolean(val) || Boolean(other.values[i]));
2084 });
2085
2086 } else if (typeof other === "boolean") {
2087
2088 this.values.forEach((val) => {
2089 newValues.push(Boolean(val) || Boolean(other));
2090 });
2091
2092 } else if (Array.isArray(other)) {
2093
2094 this.values.forEach((val, i) => {
2095 newValues.push(Boolean(val) || Boolean(other[i]));
2096 });
2097
2098 } else {
2099 throw new Error("Param Error: other must be a Series, Scalar, or Array of Scalars");
2100 }
2101
2102 return new Series(newValues, {
2103 index: this.index,
2104 config: { ...this.config }
2105 });
2106 }
2107
2108 /**
2109 * One-hot encode values in the Series.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected