danfo.DataFrame.drop(kwargs) [source]
Parameters | Type | Description | Default |
kwargs | Object | { columns: [Array(Columns| Index)] array of column names to drop index: [Array(Columns| Index)] index labels to drop axis: row=0, columns=1 inplace: specify whether to drop the row/column with/without creating a new DataFrame } | {axis: 1, inplace:false} |
Returns:
return DataFrame
By setting inplace to true, the original DataFrame is modified and nothing is returned. To not modify the original DataFrame and return a new one, set inplace to false or leave it as default.
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.drop({ columns: ["C", "B"], axis: 1, inplace: true });df.print()
╔═══╤═══════════════════╤═══════════════════╗║ │ A │ D ║╟───┼───────────────────┼───────────────────╢║ 0 │ -20 │ a ║╟───┼───────────────────┼───────────────────╢║ 1 │ 30 │ b ║╟───┼───────────────────┼───────────────────╢║ 2 │ 47.3 │ c ║╟───┼───────────────────┼───────────────────╢║ 3 │ -20 │ c ║╚═══╧═══════════════════╧═══════════════════╝
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.drop({ index: [0, 2], axis: 0, inplace: true });df.print()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗║ │ A │ B │ C │ D ║╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢║ 1 │ 30 │ -4 │ 20 │ b ║╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢║ 3 │ -20 │ 6 │ 30 │ c ║╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝
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, {index: ["a", "b", "c", "d"]})df.drop({ index: ["a", "c"], axis: 0, inplace: true });df.print()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗║ │ A │ B │ C │ D ║╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢║ b │ 30 │ -4 │ 20 │ b ║╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢║ d │ -20 │ 6 │ 30 │ c ║╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝