DataFrame.column

Return the elements of the specified column in the DataFrame

danfo.DataFrame.column(col_name) [source]

Parameters

Type

Description

Default

col_name

Str

The name of a column in the DataFrame

Returns:

return Series

Examples

Select a single column from a DataFrame

Node
Browser
Node
const dfd = require("danfojs-node")
let data = [{ "Name": ["Apples", "Mango", "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
Browser
Output
Output
╔═══╤══════════════════════╗
║ │ Name ║
╟───┼──────────────────────╢
║ 0 │ Apples ║
╟───┼──────────────────────╢
║ 1 │ Mango ║
╟───┼──────────────────────╢
║ 2 │ Banana ║
╟───┼──────────────────────╢
║ 3 │ NaN ║
╚═══╧══════════════════════╝
╔═══╤══════════════════════╗
║ │ Name ║
╟───┼──────────────────────╢
║ 0 │ Apples ║
╟───┼──────────────────────╢
║ 1 │ Mango ║
╟───┼──────────────────────╢
║ 2 │ Banana ║
╟───┼──────────────────────╢
║ 3 │ NaN ║
╚═══╧══════════════════════╝

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