Output
On this page
Methods that return PHP values, write CSV and JSON, and print tables.
PHP values
->toRows()
$table->toRows(): arrayThe rows as a list of associative arrays.
Method of DataFrame, SqlTable, PolarsTable
Returns list<array<string, mixed>>
Examples Reading and writing data, SQL tables
->toColumns()
$table->toColumns(): arrayThe columns as an array of PHP lists, keyed by name.
Method of DataFrame, SqlTable, PolarsTable
Returns array<string, list<mixed>>
->collect()
$table->collect(): DataFrameThe rows as an in-memory DataFrame. SqlTable runs its query; a DataFrame returns itself.
Method of DataFrame, SqlTable, PolarsTable
Returns DataFrame
Examples phibble for Laravel developers, SQL tables
->deframe()
$table->deframe(): arrayA two-column DataFrame as a name => value array, or a one-column DataFrame as a list, as tibble’s deframe().
Method of DataFrame
Returns array<mixed>
deframe()
deframe(DataFrame $dataFrame): arrayA two-column DataFrame as a name => value array, or a one-column DataFrame as a list, as tibble’s deframe().
| Parameter | Type | Default | Description |
|---|---|---|---|
$dataFrame |
DataFrame |
Function in Phibble
Returns array
->toCollection()
$table->toCollection(): objectAn Illuminate\Support\Collection of row arrays. Needs Laravel’s illuminate/support (or illuminate/collections) to be installed.
Method of DataFrame
Returns object
CSV and JSON
->toCsv()
$table->toCsv( string $delimiter = ',', string $na = 'NA', bool $colNames = true, string $quote = 'needed', string $escape = 'double', string $eol = '',): stringThe CSV text writeCsv() would write.
| Parameter | Type | Default | Description |
|---|---|---|---|
$delimiter |
string |
‘,’ |
|
$na |
string |
‘NA’ |
|
$colNames |
bool |
true |
|
$quote |
string |
‘needed’ |
|
$escape |
string |
‘double’ |
|
$eol |
string |
’ |
|
| ’ |
Method of DataFrame
Returns string
Examples Reading and writing data
->writeCsv()
$table->writeCsv( string $path, string $delimiter = ',', string $na = 'NA', bool $append = false, ?bool $colNames = null, string $quote = 'needed', string $escape = 'double', string $eol = '',): voidWrite CSV like readr::write_csv(): NA as “NA”, quoting only where needed, ISO dates, UTC datetimes with “Z”, TRUE/FALSE, and numbers in readr’s shortest form. $quote is ‘needed’, ‘all’ or ‘none’; $escape is ‘double’, ‘backslash’ or ‘none’. Appending skips the header unless $colNames is true.
| Parameter | Type | Default | Description |
|---|---|---|---|
$path |
string |
||
$delimiter |
string |
‘,’ |
|
$na |
string |
‘NA’ |
|
$append |
bool |
false |
|
$colNames |
?bool |
null |
|
$quote |
string |
‘needed’ |
|
$escape |
string |
‘double’ |
|
$eol |
string |
’ |
|
| ’ |
Method of DataFrame
->toJson()
$table->toJson(string $orient = 'records', int $flags = 320): stringJSON as a list of records (‘records’) or an object of columns (‘columns’). NA is null (records keep every key, unlike jsonlite); dates are “Y-m-d”, datetimes ISO 8601 in UTC with “Z”, factors their labels, NaN and infinities null, nested DataFrames nested JSON.
| Parameter | Type | Default | Description |
|---|---|---|---|
$orient |
string |
‘records’ |
|
$flags |
int |
320 |
Method of DataFrame
Returns string
Examples Reading and writing data
Printing
->__toString()
$table->__toString(): stringThe table printed as tibble prints it, for echo $df. format() takes the row count and width.
Method of DataFrame, SqlTable
Returns string
->format()
$table->format(?int $n = null, int $width = 80): stringPrint like a tibble. By default all rows are shown when there are at most 20, otherwise the first 10.
| Parameter | Type | Default | Description |
|---|---|---|---|
$n |
?int |
null |
|
$width |
int |
80 |
Method of DataFrame
Returns string
->glimpse()
$table->glimpse(int $width = 80): stringOne line per column with its type and leading values, as tibble’s glimpse().
| Parameter | Type | Default | Description |
|---|---|---|---|
$width |
int |
80 |
Method of DataFrame
Returns string
Examples Reading and writing data, Getting started, Types