DataFrame.column

Return the elements of the specified column as a Series

danfo.DataFrame.column(column)

ParametersTypeDescriptionDefault

column

String

The name of a column in the DataFrame

Examples

Select a single column from a DataFrame

const dfd = require("danfojs-node")
let data = { "Name": ["Apples", "App", "Banana", undefined],
            "Count": [NaN, 5, NaN, 10] ,
            "Price": [200, 300, 40, 250] }

let df = new dfd.DataFrame(data)

df.column("Name").print()

//Alternatively, you can retrieve columns by using the object property
df['Name'].print() //produces the same result as above
╔═══╤═══════════╗
║ 0 │ Apples    ║
╟───┼───────────╢
║ 1 │ App       ║
╟───┼───────────╢
║ 2 │ Banana    ║
╟───┼───────────╢
║ 3 │ undefined ║
╚═══╧═══════════╝

╔═══╤═══════════╗
║ 0 │ Apples    ║
╟───┼───────────╢
║ 1 │ App       ║
╟───┼───────────╢
║ 2 │ Banana    ║
╟───┼───────────╢
║ 3 │ undefined ║
╚═══╧═══════════╝

To select more than one column with specific rows, you can use any of the following: DataFrame.loc, DataFrame.iloc or DataFrame.query

Last updated