Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

VFrames

A Pandas-like DataFrame library for V, powered by DuckDB.

Overview

VFrames provides a familiar data-manipulation API for V developers, backed by an embedded DuckDB engine. Every operation compiles down to SQL and runs inside DuckDB's vectorized query executor — giving you fast in-memory analytics with a concise, expressive API.

Features

  • Pandas-like API — familiar method names for data scientists coming from Python
  • DuckDB backend — vectorized execution, analytical SQL functions, columnar storage
  • Multiple file formats — read and write CSV, JSON, Parquet, and Excel, with auto-detection
  • Remote & cloud sources — read directly from HTTPS URLs and S3 (and other cloud schemes)
  • Live databases — attach and query Postgres, MySQL, SQLite, and DuckDB databases
  • Immutable design — every operation returns a new DataFrame; originals are never mutated
  • Lazy by default — transformations build DuckDB views (no data copies); call df.collect() to materialize a result
  • Full error propagation — no hidden panics; errors surface as V result types (!T)
  • Rich function set — filtering, grouping, joins, pivots, rolling windows, cumulative ops, and more

Installation

# 1. Install the DuckDB V bindings
v install https://github.com/rodabt/vduckdb
# 2. Install VFrames
v install https://github.com/rodabt/vframes

Ensure LIBDUCKDB_DIR points to the directory containing libduckdb.so / libduckdb.dylib.

Quick Start

importvframesimportx.json2fnmain() {
mutctx:= vframes.init()!defer { ctx.close() }
// Load from a file (CSV, JSON, or Parquet — detected automatically)df:= ctx.read_auto('employees.csv')!// Or build from in-memory recordsdata:= [
{'name': json2.Any('Alice'), 'dept': json2.Any('Eng'), 'salary': json2.Any(90000)},
{'name': json2.Any('Bob'), 'dept': json2.Any('Sales'), 'salary': json2.Any(70000)},
{'name': json2.Any('Carol'), 'dept': json2.Any('Eng'), 'salary': json2.Any(95000)},
]
df2:= ctx.read_records(data)!// Exploreprintln('Shape: ${df2.shape()!}') // [3, 3]println('Columns: ${df2.columns()!}') // ['name', 'dept', 'salary']
df2.head(5)!// Transformdf3:= df2
.filter('salary > 75000')!
.add_column('bonus', 'salary * 0.1')!
.sort_values(['salary'], ascending: false)!// Aggregateby_dept:= df2.group_by(['dept'], {
'avg_salary': 'avg(salary)',
'headcount': 'count(*)',
})!
by_dept.head(10)!// Export
df3.to_csv('/tmp/result.csv', vframes.ToCsvOptions{})!println(df3.to_markdown()!)
}

Core Concepts

Context

All DataFrames live inside a DataFrameContext, which owns the DuckDB connection. Open one context per workflow and close it when done:

mutctx:= vframes.init()!// in-memory (default)mutctx:= vframes.init(location: 'data.db')!// persisted to diskdefer { ctx.close() }

Immutability

Every method returns a new DataFrame backed by a new DuckDB table. Originals are untouched:

df2:= df.add_column('tax', 'salary * 0.2')!// df still has the original columns; df2 has the extra column

Lazy views & collect()

Each transformation returns a new DataFrame backed by a DuckDB view, not a copied table — so chaining operations costs no extra memory. The query runs only at a materialization point (head, values, to_csv, shape, …).

result:= df.filter('age > 25')!.add_column('bonus', 'salary*0.1')!// views, no data copiedfinal:= result.collect()!// materialize into a real table for reuse

collect() (and its alias copy()) snapshot a chain into an independent table — useful for an expensive intermediate you reuse, or to keep a result alive while the rest is discarded. Inspect state with df.is_lazy()! / df.object_type()!. Very deep chains print a one-time hint to call collect(); tune or disable it with init(view_depth_warning: N) (0 disables). Base read_* operations and pivot materialize real tables.

Error handling

Functions return !T. Propagate with ! or handle inline with or {}:

df:= ctx.read_auto('missing.csv')!// panics on errordf:= ctx.read_auto('missing.csv') or { // handle gracefullyeprintln('File not found: ${err}')
return
}

API Summary

I/O

FunctionDescription
ctx.read_auto(path)!Read CSV / JSON / Parquet / Excel (local or remote), auto-detected
ctx.read_csv(path, opts)!Read CSV with options (delimiter, header, column types, glob)
ctx.read_json(path, opts)!Read JSON (local or remote)
ctx.read_parquet(path, opts)!Read Parquet, supports glob and remote URLs
ctx.read_excel(path, opts)!Read an .xlsx file (excel extension)
ctx.read_records(data)!Load from []map[string]json2.Any
df.to_csv(path, opts)!Export to CSV
df.to_json(path)!Export to newline-delimited JSON
df.to_parquet(path)!Export to Parquet
df.to_excel(path, opts)!Export to .xlsx (excel extension)
df.to_dict()!Return all rows as []map[string]json2.Any
df.to_markdown()!Return DataFrame as a Markdown table string
df.to_html()!Return DataFrame as an HTML <table> string

DuckDB extensions required by remote, Excel, and database I/O (httpfs, excel, postgres/mysql/sqlite) are auto-installed on first use.

Loading data

df:= ctx.read_csv('data.csv', delimiter: ';')!// local or remotedf:= ctx.read_parquet('s3://bucket/*.parquet')!// glob + clouddf:= ctx.read_excel('report.xlsx', sheet: 'Q1')!// Exceldf:= ctx.read_json('https://host/data.json')!// remote JSON

Databases

ctx.attach('host.db', alias: 'src', db_type: .sqlite)!people:= ctx.read_table('src.people')!
people.to_sql('backup', alias: 'src', if_exists: 'replace')!
ctx.detach('src')!// one-shot: attach, read, detachdf:= ctx.read_database('host.db', 'SELECT * FROM s.t', alias: 's', db_type: .sqlite)!// raw SQL escape hatch against any loaded/attached tabledf2:= ctx.read_sql('SELECT * FROM src.people WHERE age > 30')!

Cloud credentials

ctx.set_s3_credentials(key_id: '...', secret: '...', region: 'us-west-2')!

Exporting

df.to_excel('out.xlsx')!html:= df.to_html()!

Exploration

FunctionReturnsDescription
df.head(n, cfg)!DataFirst N rows
df.tail(n, cfg)!DataLast N rows
df.shape()![]int[rows, cols]
df.columns()![]stringColumn names
df.dtypes()!map[string]stringColumn types
df.describe(cfg)!DataSummary statistics
df.info(cfg)!DataColumn names and types
df.values(opts)!DataAll rows

Selection & Mutation

FunctionDescription
df.subset(cols)!Select columns by name
df.select_cols(cols)!Alias for subset
df.slice(start, end)!Select row range (1-indexed, inclusive)
df.filter(condition)!Filter rows by SQL WHERE condition
df.query(expr, cfg)!SQL column expression or SELECT cols WHERE cond
df.add_column(name, expr)!Add column via SQL expression
df.assign(name, expr)!Alias for add_column
df.delete_column(name)!Remove one column
df.drop(cols)!Remove multiple columns
df.rename(mapper)!Rename columns via map[string]string
df.add_prefix(p)!Prepend p_ to all column names
df.add_suffix(s)!Append _s to all column names
df.sort_values(cols, opts)!Sort by one or more columns
df.astype(map)!Convert column types
df.replace(old, new)!Replace string values
df.isin(values)!Boolean mask for listed values

Joins & Reshaping

FunctionDescription
df1.merge(df2, on: 'col', how: 'inner')!SQL join
df1.join(df2, on: 'col')!Alias for merge
vframes.concat([df1, df2])!Stack DataFrames vertically
df.pivot(index, columns, values, aggfunc)!Long → wide
df.pivot_table(...)!Alias for pivot
df.melt(id_vars, value_vars)!Wide → long
df.drop_duplicates(subset)!Remove duplicate rows
df.sample(n, replace)!Random sample

Aggregation & Statistics

FunctionDescription
df.group_by(dims, metrics)!Group and aggregate
df.groupby(...)!Alias for group_by
df.agg(map)!Aggregate without grouping
df.sum(opts)!Column-wise sum
df.mean(opts)!Column-wise mean
df.median(opts)!Column-wise median
df.std()!Standard deviation
df.var()!Variance
df.min(opts)! / df.max(opts)!Min / max
df.count()!Non-null counts
df.nunique()!Distinct-value counts
df.nlargest(n)! / df.nsmallest(n)!Top / bottom N rows
df.quantile(q)!Percentile (0.0 – 1.0)
df.corr()! / df.cov()!Correlation / covariance matrices

Element-wise Math

FunctionDescription
df.add(n)! / df.sub(n)! / df.mul(n)! / df.div(n)!Scalar arithmetic
df.floordiv(n)! / df.mod(n)!Integer division, modulo
df.abs()!Absolute value
df.pow(n, opts)!Power
df.round(decimals)!Round
df.clip(min, max)!Clamp to range

Cumulative & Time-Series

FunctionDescription
df.cumsum()! / df.cummax()! / df.cummin()! / df.cumprod()!Cumulative aggregates
df.shift(n)!Shift rows by N periods
df.diff()!Row-to-row difference
df.pct_change()!Row-to-row % change
df.rolling(col, func, opts)!Rolling window aggregate
df.rank(opts)!Row ranking

Missing Values

FunctionDescription
df.isna()! / df.isnull()!Boolean null mask
df.notna()! / df.notnull()!Boolean non-null mask
df.dropna(opts)!Drop rows with nulls
df.fillna(opts)!Fill nulls with constant
df.ffill()! / df.bfill()!Forward / backward fill

Documentation

  • Tutorial — side-by-side guide with Pandas comparisons
  • Examples — runnable end-to-end scripts

Requirements

  • V (Vlang) compiler
  • DuckDB shared library (LIBDUCKDB_DIR environment variable)

License

MIT License — see LICENSE for details.

About

A powerful data manipulation library inspired by Pandas, designed specifically for the V language, using VDuckDB under the hood.

Topics

Resources

Code of conduct

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages