DataFrame.ctypes
Return the inferred column types in the DataFrame. This returns a Series with the data type of each column. The result’s index is the original DataFrame’s columns.
danfo.DataFrame.dtypes [source]
Returns:
return Series

Examples

Returns auto-generated index of a DataFrame
Node
Browser
1
const dfd = require("danfojs-node")
2
3
let data = {"A": [-20.1, 30, 47.3, -20],
4
"B": [34, -4, 5, 6],
5
"C": [20, -20, 30, -40]}
6
7
let df = new dfd.DataFrame(data)
8
9
df.ctypes.print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ A │ float32 ║
5
╟───┼──────────────────────╢
6
║ B │ int32 ║
7
╟───┼──────────────────────╢
8
║ C │ int32 ║
9
╚═══╧══════════════════════╝
Copied!
Columns with mixed types are represented as string.
Node
Browser
1
2
const dfd = require("danfojs-node")
3
4
let data = {"A": [-20.1, 30, 47.3, -20],
5
"B": [34, -4, 5, 6],
6
"C": [20, -20, 30, -40],
7
"D": ["a", "b", 20, 2.5]}
8
9
let df = new dfd.DataFrame(data)
10
11
df.ctypes.print()
Copied!
1
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ A │ float32 ║
5
╟───┼──────────────────────╢
6
║ B │ int32 ║
7
╟───┼──────────────────────╢
8
║ C │ int32 ║
9
╟───┼──────────────────────╢
10
║ D │ string ║
11
╚═══╧══════════════════════╝
Copied!
Note: To cast a type, use the astype method.
Last modified 1yr ago
Copy link
Contents
Examples