Public
Edited
Nov 11, 2023
Importers
Insert cell
Insert cell
Insert cell
function typeFind(arr) {
const firstRow = arr[0];
const cols = arr.columns;
const df = [];
for (let col of cols) {
// find first non-missing value:
let value;
for (let i = 0; i < arr.length; i++) {
value = arr[i][col];
// some csvs from R data frames might represent unassigned as "NA":
let missing = (value === null || typeof value === "undefined" || value === "NA")
if (!missing) {
break;
}
}
const hasProtoType = value instanceof Object;
if (hasProtoType) {
df.push({column: col, type: value.constructor.name});
} else {
df.push({column: col, type: typeof value});
}
}
return df;
}
Insert cell
Inputs.table(typeFind(olympians))
Insert cell
import {planes} from "@homerhanumat/nycflights13"
Insert cell
Inputs.table(typeFind(planes))
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more