Links

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

Examples

Returns auto-generated index of a DataFrame
Node
Browser
const dfd = require("danfojs-node")
let data = {"A": [-20.1, 30, 47.3, -20],
"B": [34, -4, 5, 6],
"C": [20, -20, 30, -40]}
let df = new dfd.DataFrame(data)
df.ctypes.print()
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ A │ float32 ║
╟───┼──────────────────────╢
║ B │ int32 ║
╟───┼──────────────────────╢
║ C │ int32 ║
╚═══╧══════════════════════╝
Columns with mixed types are represented as string.
Node
Browser
const dfd = require("danfojs-node")
let data = {"A": [-20.1, 30, 47.3, -20],
"B": [34, -4, 5, 6],
"C": [20, -20, 30, -40],
"D": ["a", "b", 20, 2.5]}
let df = new dfd.DataFrame(data)
df.ctypes.print()
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ A │ float32 ║
╟───┼──────────────────────╢
║ B │ int32 ║
╟───┼──────────────────────╢
║ C │ int32 ║
╟───┼──────────────────────╢
║ D │ string ║
╚═══╧══════════════════════╝
Note: To cast a type, use the asType method.