danfo.DataFrame.sample(num, seed) [source]
Parameters | Type | Description | Default |
num | Int | The number of rows to return. Defaults to -1, which shuffles and return all rows. | -1 |
seed | int | An integer specifying the random seed that will be used to create the distribution. Ensures reproducibility of generated samples. | 1 |
Returns:
return {Promies} resolves to DataFrame
const dfd = require("danfojs-node")async function load_data() {let data = {Name: ["Apples", "Mango", "Banana", "Pear"],Count: [21, 5, 30, 10],Price: [200, 300, 40, 250],};let df = new dfd.DataFrame(data);let s_df = await df.sample(2);s_df.print();}load_data()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗║ │ Name │ Count │ Price ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 0 │ Apples │ 21 │ 200 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 2 │ Banana │ 30 │ 40 ║╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝