DataFrame.column
Return the elements of the specified column in the DataFrame
danfo.DataFrame.column(column) [source]
Parameters
Type
Description
Default
column
String
The name of a column in the DataFrame
Returns:
return Series

Examples

Select a single column from a DataFrame

Node
Browser
1
const dfd = require("danfojs-node")
2
let data = { "Name": ["Apples", "App", "Banana", undefined],
3
"Count": [NaN, 5, NaN, 10] ,
4
"Price": [200, 300, 40, 250] }
5
6
let df = new dfd.DataFrame(data)
7
8
df.column("Name").print()
9
10
//Alternatively, you can retrieve columns by using the object property
11
df['Name'].print() //produces the same result as above
12
Copied!
1
Copied!
Output
1
╔═══╤═══════════╗
2
║ 0 │ Apples ║
3
╟───┼───────────╢
4
║ 1 │ App ║
5
╟───┼───────────╢
6
║ 2 │ Banana ║
7
╟───┼───────────╢
8
║ 3 │ undefined ║
9
╚═══╧═══════════╝
10
11
╔═══╤═══════════╗
12
║ 0 │ Apples ║
13
╟───┼───────────╢
14
║ 1 │ App ║
15
╟───┼───────────╢
16
║ 2 │ Banana ║
17
╟───┼───────────╢
18
║ 3 │ undefined ║
19
╚═══╧═══════════╝
20
Copied!
To select more than one column with specific rows, you can use any of the following: DataFrame.loc, DataFrame.iloc or DataFrame.query
Last modified 17d ago