DocsData & AIData Subsystem & Columnar DataFrames
Data & AI

Data Subsystem & Columnar DataFrames

Columnar data processing, automated CSV loading, schema validation, and dataset transformations.

idtimestampmetric10112:00:0198.410212:00:0299.1

NextViper Data Subsystem API Reference

Module: `data`

The data module provides utilities for creating, loading, inspecting, transforming, and processing tabular data and numerical arrays.


1

Top-Level Functions

`data.load(path: string) -> DataFrame`

Loads a dataset from disk, automatically detecting format by file extension (.csv, .json, .jsonl).

main.nv
import data

let df = data.load("users.csv")

`data.read_csv(content_or_path: string) -> DataFrame`

Parses CSV content from a string or reads a CSV file from a path.

main.nv
let df = data.read_csv("name,age
Alice,30
Bob,25
")

`data.read_json(content_or_path: string) -> DataFrame`

Parses JSON array of objects or line-delimited JSON (JSONL).

main.nv
let df = data.read_json("[{"name": "Alice", "age": 30}]")

`data.array(values: list[float|int]) -> DataArray`

Creates a numerical array from a list of numbers.

main.nv
let arr = data.array([1.0, 2.0, 3.0, 4.0, 5.0])

`data.zeros(shape: list[int]|int) -> DataArray`

Creates an array of zeros with the specified shape.

main.nv
let z = data.zeros([100, 4])

`data.ones(shape: list[int]|int) -> DataArray`

Creates an array of ones with the specified shape.

main.nv
let o = data.ones([10, 10])

`data.arange(start: float, stop: float, step: float = 1.0) -> DataArray`

Generates evenly spaced values within a given half-open interval [start, stop).

main.nv
let r = data.arange(0.0, 10.0, 0.5)

`data.linspace(start: float, stop: float, num: int = 50) -> DataArray`

Generates num evenly spaced numbers over the closed interval [start, stop].

main.nv
let grid = data.linspace(0.0, 1.0, 100)

2

`DataFrame` Methods

MethodReturn TypeDescription
`df.columns``list[string]`List of column names in the table
`df.shape``list[int]``[num_rows, num_cols]` dimensions
`df.num_rows``int`Total number of rows
`df.num_cols``int`Total number of columns
`df.select(columns: list[string])``DataFrame`Projects a subset of columns
`df.drop(columns: list[string])``DataFrame`Drops specified columns
`df.head(n: int = 5)``DataFrame`Returns the first `n` rows
`df.tail(n: int = 5)``DataFrame`Returns the last `n` rows
`df.sort(column: string, asc: bool = true)``DataFrame`Sorts rows by column value
`df.clean(drop_nulls: bool = true)``DataFrame`Cleans missing values
`df.drop_missing()``DataFrame`Drops any rows containing nulls
`df.shuffle(seed: int = 42)``DataFrame`Deterministically shuffles rows
`df.split(train_ratio: float, seed: int)``list[DataFrame]`Splits into `[train_df, test_df]`
`df.normalize()``DataFrame`Min-max normalizes numeric columns to `[0, 1]`
`df.standardize()``DataFrame`Standardizes numeric columns to mean=0, std=1
`df.describe()``map[string, map]`Returns summary statistics (`count`, `mean`, `min`, `max`, `std`, `nulls`)
`df.to_tensor(columns = [])``Tensor`Converts numeric columns into a 2D `Tensor`
`df.to_array(column: string)``DataArray`Converts a single column into a `DataArray`
`df.to_csv()``string`Serializes DataFrame into CSV formatted text
`df.to_json()``string`Serializes DataFrame into JSON array of objects

3

`DataArray` Methods

MethodReturn TypeDescription
`arr.shape``list[int]`Dimensions of the array
`arr.size``int`Total number of elements
`arr.mean()``float`Arithmetic mean of elements
`arr.sum()``float`Total sum of elements
`arr.min()``float`Minimum element value
`arr.max()``float`Maximum element value
`arr.std()``float`Standard deviation
`arr.var()``float`Variance
`arr.median()``float`Median value
`arr.normalize(min=0.0, max=1.0)``DataArray`Scales array elements into `[min, max]`
`arr.standardize()``DataArray`Normalizes to zero mean and unit variance
`arr.to_tensor()``Tensor`Zero-copy conversion into a `Tensor`

NextViper Data Subsystem Tutorial: From CSV to Model-Ready Data

In this tutorial, you will learn how to load a dataset, inspect its structure, clean missing values, transform numeric features, and prepare train/test splits for training.


1

Loading and Inspecting a Dataset

Create a sample CSV file housing.csv:

csv
rooms,sqft,age,price
3,1200.0,10,250000.0
4,1850.0,5,380000.0
2,850.0,null,175000.0
5,2400.0,2,490000.0
3,1350.0,15,270000.0

Load the CSV into NextViper:

main.nv
import data
import std.io

// 1. Load the dataset
let df = data.load("housing.csv")

// 2. Inspect dimensions and columns
io.print("Shape (rows, cols):", df.shape)
io.print("Columns:", df.columns)

// 3. View the first 3 rows
let preview = df.head(3)
io.print(preview.to_csv())

Output:

code
Shape (rows, cols): [5, 4]
Columns: ["rooms", "sqft", "age", "price"]
rooms,sqft,age,price
3,1200,10,250000
4,1850,5,380000
2,850,,175000

2

Cleaning Missing Values

Real-world datasets often contain missing (null) entries. You can clean them with .drop_missing():

main.nv
// Remove all rows with missing values
let clean_df = df.drop_missing()
io.print("Clean rows count:", clean_df.num_rows)

Output:

code
Clean rows count: 4

3

Summary Statistics

Generate statistical descriptions (count, mean, min, max, std):

main.nv
let stats = clean_df.describe()
io.print("Mean square footage:", stats["sqft"]["mean"])
io.print("Max price:", stats["price"]["max"])

4

Feature Normalization & Splitting

Before training machine learning models, features should be normalized and split into training and test partitions:

main.nv
// 1. Min-Max normalize numeric columns to [0.0, 1.0]
let normalized_df = clean_df.normalize()

// 2. Deterministically shuffle data with seed
let shuffled_df = normalized_df.shuffle(42)

// 3. Split into 80% train and 20% test sets
let split_pair = shuffled_df.split(0.8, 42)
let train_set = split_pair[0]
let test_set = split_pair[1]

io.print("Training set rows:", train_set.num_rows)
io.print("Testing set rows:", test_set.num_rows)

5

Converting to Tensors

Convert preprocessed features into Tensor instances ready for neural networks:

main.nv
let feature_cols = ["rooms", "sqft", "age"]
let train_tensors = train_set.to_tensor(feature_cols)

io.print("Tensor Shape:", train_tensors.shape)

Output:

code
Tensor Shape: [3, 3]

You are now ready to feed your preprocessed data directly into the NextViper AI and neural network pipelines!