Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Merge 2aa0b2d into 1ef2d46
Browse files Browse the repository at this point in the history
  • Loading branch information
caseycrogers committed Dec 11, 2020
2 parents 1ef2d46 + 2aa0b2d commit 5767ff9
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 107 deletions.
22 changes: 11 additions & 11 deletions README.md
Expand Up @@ -11,7 +11,7 @@ A dataframe for Dart
From csv:

```dart
final df = await DataFrame.fromCsv("dataset/stocks.csv");
final df = await DataFrame.fromCsv('dataset/stocks.csv');
```

Note: the type of the records are infered from the data. The first line of the csv must contains the headers for the column names. Optional parameters:
Expand All @@ -28,8 +28,8 @@ From records:

```dart
final rows = <Map<String, dynamic>> rows[
<String, dynamic>{"col1": 21, "col2": "foo", "col3": DateTime.now()},
<String, dynamic>{"col1": 22, "col2": "bar", "col3": DateTime.now()},
<String, dynamic>{'col1': 21, 'col2': 'foo', 'col3': DateTime.now()},
<String, dynamic>{'col1': 22, 'col2': 'bar', 'col3': DateTime.now()},
];
final df = DataFrame.fromRows(rows);
```
Expand All @@ -41,7 +41,7 @@ From records:
// select a subset of rows
final List<Map<String, dynamic>> rows = df.subset(0,100);
/// select records for a column
final List<double> values = df.colRecords<double>("col2");
final List<double> values = df.colRecords<double>('col2');
/// select list of records
final List<List<dynamic>> records = df.records;
```
Expand All @@ -52,7 +52,7 @@ Add data:

```dart
// add a row
df.addRow(<String,dynamic>{"col1": 1, "col2": 2.0});
df.addRow(<String,dynamic>{'col1': 1, 'col2': 2.0});
// add a line of records
df.addRecord(<dynamic>[1, 2.0]);
```
Expand Down Expand Up @@ -82,17 +82,17 @@ Copy a dataframe:
Nulls and zeros:

```dart
final int n = df.countNulls_("col1");
final int n = df.countZeros_("col1");
final int n = df.countNulls_('col1');
final int n = df.countZeros_('col1');
```

Columns:

```dart
final int mean = df.mean("col1");
final int sum = df.sum("col1");
final int max = df.max("col1");
final int min = df.min("col1");
final int mean = df.mean('col1');
final int sum = df.sum('col1');
final int max = df.max('col1');
final int min = df.min('col1');
```

### Info
Expand Down
4 changes: 2 additions & 2 deletions example/main.dart
@@ -1,8 +1,8 @@
import 'package:df/df.dart';

Future<void> main() async {
final df = await DataFrame.fromCsv("dataset/stocks.csv",
dateFormat: "MMM dd yyyy", verbose: true);
final df = await DataFrame.fromCsv('dataset/stocks.csv',
dateFormat: 'MMM dd yyyy', verbose: true);
df.show();
print(df.columns);
}
2 changes: 1 addition & 1 deletion lib/src/column.dart
Expand Up @@ -40,7 +40,7 @@ class DataFrameColumn {

@override
String toString() {
return "$name ($type)";
return '$name ($type)';
}

@override
Expand Down
20 changes: 10 additions & 10 deletions lib/src/df.dart
Expand Up @@ -121,7 +121,7 @@ class DataFrame {
bool verbose = false}) async {
final file = File(path);
if (!file.existsSync()) {
throw FileNotFoundException("File not found: $path");
throw FileNotFoundException('File not found: $path');
}
final df = DataFrame();
var i = 1;
Expand All @@ -132,7 +132,7 @@ class DataFrame {
.transform<String>(const LineSplitter())
.forEach((line) {
//print('line $i: $line');
final vals = line.split(",");
final vals = line.split(',');
if (i == 1) {
// set columns names
_colNames = vals;
Expand Down Expand Up @@ -160,7 +160,7 @@ class DataFrame {
++i;
});
if (verbose) {
print("Parsed ${df._matrix.data.length} rows");
print('Parsed ${df._matrix.data.length} rows');
}
return df;
}
Expand Down Expand Up @@ -232,10 +232,10 @@ class DataFrame {
int countNulls_(String colName,
{List<dynamic> nullValues = const <dynamic>[
null,
"null",
"nan",
"NULL",
"N/A"
'null',
'nan',
'NULL',
'N/A'
]}) {
final n = _matrix.countForValues(_indiceForColumn(colName), nullValues);
return n;
Expand Down Expand Up @@ -307,13 +307,13 @@ class DataFrame {
}
final rows = _matrix.data.sublist(0, l);
_info.printRows(rows);
print("$length rows");
print('$length rows');
}

/// Print info and sample data
void show([int lines = 5]) {
print(
"${_columns.length} columns and $length rows: ${columnsNames.join(", ")}");
'${_columns.length} columns and $length rows: ${columnsNames.join(', ')}');
var l = lines;
if (length < lines) {
l = length;
Expand Down Expand Up @@ -389,7 +389,7 @@ class DataFrame {
++i;
}
if (ind == null) {
throw ColumnNotFoundException("Can not find column $colName");
throw ColumnNotFoundException('Can not find column $colName');
}
return ind;
}
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Expand Up @@ -7,11 +7,11 @@ environment:
sdk: ">=2.4.0 <3.0.0"

dependencies:
meta: ^1.1.8
pedantic: ^1.8.0
extra_pedantic: ^1.1.1+3
ml_linalg: ^12.7.1
jiffy: ^3.0.1
meta: ^1.1.8
ml_linalg: ^12.7.1
pedantic: ^1.8.0

dev_dependencies:
test: ^1.6.5
Expand Down

0 comments on commit 5767ff9

Please sign in to comment.