DataFrame.nUnique
Returns the number of unique elements in a column, across the specified axis.
danfo.DataFrame.nUnique(axis) [source]
Examples
Return number of unique values along default axis (axis=1)
const dfd = require("danfojs-node")
let data = { "A": [-20, 30, 47.3, -20] ,
"B": [34, -4, 5, 6] ,
"C": [20, 20, 30, 30],
"D": ["a", "b", "c", "c"] }
let df = new dfd.DataFrame(data)
df.nunique().print()
╔═══╤═══╗
║ 0 │ 4 ║
╟───┼───╢
║ 1 │ 4 ║
╟───┼───╢
║ 2 │ 4 ║
╟───┼───╢
║ 3 │ 4 ║
╚═══╧═══╝
Return number of unique values in row axis (axis=0)
const dfd = require("danfojs-node")
let data = { "A": [-20, 30, 47.3, -20] ,
"B": [34, -4, 5, 6] ,
"C": [20, 20, 30, 30],
"D": ["a", "b", "c", "c"] }
let df = new dfd.DataFrame(data)
df.nUnique(axis=0).print()
╔═══╤═══╗
║ A │ 3 ║
╟───┼───╢
║ B │ 4 ║
╟───┼───╢
║ C │ 2 ║
╟───┼───╢
║ D │ 3 ║
╚═══╧═══╝
Note: To get the unique elements along an axis, see DataFrame.unique.