df 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

Df #

pub package Build Status Coverage Status

A dataframe for Dart

Usage #

Create #

From 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:

dateFormat: the string format of the date: reference. Ex: MMM dd yyyy

timestampCol: the column to be treated as a timestamp. Ex: timestamp

timestampFormat: the format of the timestamp: seconds, milliseconds or microseconds. Ex: TimestampFormat.microseconds

verbose: set to true to print some info

From records:

   final rows = <Map<String, dynamic>> rows[
      <String, dynamic>{"col1": 21, "col2": "foo", "col3": DateTime.now()},
      <String, dynamic>{"col1": 22, "col2": "bar", "col3": DateTime.now()},
   final df = DataFrame.fromRows(rows);

Select #

   final List<Map<String, dynamic>> rows = df.rows;
   // 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");
   /// select list of records
   final List<List<dynamic>> records = df.records;

Mutate #

Add data:

   // add a row
   df.addRow(<String,dynamic>{"col1": 1, "col2": 2.0});
   // add a line of records
   df.addRecord(<dynamic>[1, 2.0]);

Remove data:

   // remove the third row
   // limit the dataframe to 100 rows starting from index 30
   df.limit(100, startIndex: 30);

Copy a dataframe:

   // get a new dataframe from the existing one
   final DataFrame df2 = df.copy_();
   // get a new dataframe with limited data
   final DataFrame df2 = df.limit_(100);

Count #

Nulls and zeros:

   final int n = df.countNulls_("col1");
   final int n = df.countZeros_("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 #

   final int numRecords= df.length;
   final List<DataFrameColumn> cols = df.columns;
   final List<String> colNames = df.columnsNames;
   // print info and sample data
   // like head with a bit more details

Conventions #

All the dataframe operations are inplace. All the methods that return objects end with an underscore. Example:

   // inplace
   // get a new dataframe with limited data
   final DataFrame df2 = df.limit_(30);

Vocabulary conventions:

  • A row is a map of key/values pair
  • A record is a single cell value
  • An index is a row position
  • An indice is a column position

Changelog #

0.2.1 #

  • Improve the tests
  • Improve the docs

0.2.0 #

  • Add support for timestamp formats
  • Update dependencies

0.1.0 #



import 'package:df/df.dart';

Future<void> main() async {
  final df = await DataFrame.fromCsv("dataset/stocks.csv",
      dateFormat: "MMM dd yyyy", verbose: true);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  df: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:df/df.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Analysis suggestions

Package not compatible with SDK dart


  • df that depends on:
  • jiffy that is a package requiring null.

Package not compatible with runtime flutter-web on web


  • package:df/df.dart that imports:
  • package:df/src/df.dart that imports:
  • dart:io


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
extra_pedantic ^1.1.1+3 1.2.0
jiffy ^3.0.1 3.0.1
meta ^1.1.8 1.2.1
ml_linalg ^12.7.1 12.17.1
pedantic ^1.8.0 1.9.1
Transitive dependencies
injector 1.0.8
intl 0.16.1
matcher 0.12.8
path 1.7.0
quiver 2.1.3
stack_trace 1.9.5
xrange 0.0.8
Dev dependencies
test ^1.6.5
test_coverage ^0.4.0