Danfo.js
Getting Started
API Reference
Contributing Guide
Github
Search…
Danfo.js Documentation
Getting Started
API reference
General Functions
Input/Output
Series
Dataframe
Creating a DataFrame
DataFrame.sortIndex
DataFrame.append
DataFrame.nUnique
DataFrame.tensor
DataFrame.print
DataFrame.toCSV
DataFrame.toJSON
DataFrame.toExcel
DataFrame.sortValues
DataFrame.setIndex
DataFrame.resetIndex
DataFrame.rename
DataFrame.drop
DataFrame.asType
DataFrame.shape
DataFrame.axis
DataFrame.ndim
DataFrame.values
DataFrame.selectDtypes
DataFrame.ctypes
DataFrame.index
DataFrame.loc
DataFrame.iloc
DataFrame.at
DataFrame.iat
DataFrame.head
DataFrame.tail
DataFrame.sample
DataFrame.add
DataFrame.sub
DataFrame.mul
DataFrame.div
DataFrame.pow
DataFrame.mod
DataFrame.mean
DataFrame.median
DataFrame.min
DataFrame.max
DataFrame.std
DataFrame.var
DataFrame.count
DataFrame.round
DataFrame.cumSum
DataFrame.cumMin
DataFrame.cumMax
DataFrame.cumProd
DataFrame.copy
DataFrame.describe
DataFrame.sum
DataFrame.abs
DataFrame.query
DataFrame.addColumn
DataFrame.groupby
DataFrame.column
DataFrame.fillNa
DataFrame.isNa
DataFrame.dropNa
DataFrame.apply
DataFrame.applyMap
DataFrame.It
DataFrame.gt
DataFrame.le
DataFrame.ge
DataFrame.ne
DataFrame.eq
DataFrame.replace
Configuration Options
Plotting
Groupby
User Guides
Building Data Driven Applications with Danfo.js - Book
Contributing Guide
Release Notes
Powered By
GitBook
DataFrame.mul
Get Multiplication of dataframe and other, element-wise (binary operator mul).
danfo.DataFrame.mul(other, option)
Parameters
Type
Description
Default
other
DataFrame, Series, Array or Scalar
Object to multiply with
option
Object
{
axis
: 0 for row, 1 for column.
inplace
: Boolean indicating whether to perform the operation inplace or not. Defaults to false
}
{ axis: 1, inplace: false }
Examples
Multiplication of
scalar with
DataFrame along default axis 1
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
10
,
45
,
56
,
10
],
5
"Col2"
:
[
23
,
20
,
10
,
24
]
6
}
7
let
df
=
new
dfd
.
DataFrame
(
data
)
8
9
let
df_new
=
df
.
mul
(
2
)
10
11
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 20 │ 46 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 90 │ 40 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 112 │ 20 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 20 │ 48 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
Copied!
Multiplication of
Series with
DataFrame along axis 0
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
1
,
4
,
5
,
1
],
5
"Col2"
:
[
3
,
2
,
0
,
4
]
6
}
7
8
let
df
=
new
dfd
.
DataFrame
(
data
)
9
let
sf
=
new
dfd
.
Series
([
4
,
5
])
10
11
let
df_new
=
df
.
mul
(
sf
,
{
axis
:
1
})
12
13
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 4 │ 15 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 16 │ 10 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 20 │ 0 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 4 │ 20 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
Copied!
Multiplication of DataFrame
with
another DataFrame
Node
Browser
1
const
dfd
=
require
(
"danfojs"
)
2
3
let
data
=
{
"Col1"
:
[
1
,
4
,
5
,
0
],
4
"Col2"
:
[
2
,
0
,
1
,
4
]}
5
6
let
data2
=
{
"new_col1"
:
[
1
,
5
,
20
,
10
],
7
"new_Col2"
:
[
20
,
2
,
1
,
2
]}
8
9
let
df
=
new
dfd
.
DataFrame
(
data
)
10
let
df2
=
new
dfd
.
DataFrame
(
data2
)
11
12
let
df_new
=
df
.
mul
(
df2
)
13
14
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 1 │ 40 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 20 │ 0 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 100 │ 1 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 0 │ 8 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
Copied!
Multiplication of Array
with
DataFrame along axis 0
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
10
,
45
,
56
,
10
],
5
"Col2"
:
[
23
,
20
,
10
,
24
]
6
}
7
8
let
df
=
new
dfd
.
DataFrame
(
data
)
9
let
val
=
[
2
,
2
,
2
,
2
]
10
11
let
df_new
=
df
.
mul
(
val
,
{
axis
:
0
})
12
13
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 20 │ 46 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 90 │ 40 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 112 │ 20 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 20 │ 48 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
12
Copied!
Multiplication works inplace
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
10
,
45
,
56
,
10
],
5
"Col2"
:
[
23
,
20
,
10
,
24
]
6
}
7
8
let
df
=
new
dfd
.
DataFrame
(
data
)
9
let
val
=
[
2
,
2
,
2
,
2
]
10
11
df
.
mul
(
val
,
{
axis
:
0
,
inplace
:
true
})
12
13
df
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 20 │ 46 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 90 │ 40 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 112 │ 20 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 20 │ 48 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
Copied!
Previous
DataFrame.sub
Next
DataFrame.div
Last modified
3mo ago
Copy link
Contents
Examples
Multiplication of scalar with DataFrame along default axis 1
Multiplication of Series with DataFrame along axis 0
Multiplication of DataFrame with another DataFrame
Multiplication of Array with DataFrame along axis 0
Multiplication works inplace