A tutorial on Julia DataFrames package
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

An Introduction to DataFrames

Bogumił Kamiński, September 10, 2018

The tutorial works with Julia 1.0. A major change is moving from JLD to JLD2 package.

A brief introduction to basic usage of DataFrames. Tested under Julia 1.0.0, DataFrames 0.13.1 (at least master for August 31, 2018 required), CSV 0.3.1, CSVFiles 0.9.1, JLD2 0.1.2, FileIO 1.0.1, CategoricalArrays 0.3.13, FreqTables 0.3.0, DataFramesMeta 0.4.0, StatPlots 0.8.1. Also package BencmarkTools is used as a utility.

I will try to keep it up to date as the package evolves. This tutorial covers DataFrames, CSV, CSVFiles, JLD2, and CategoricalArrays, as they constitute the core of DataFrames.

In the last extras part mentions selected functionalities of selected useful packages that I find useful for data manipulation, currently those are: FreqTables, DataFramesMeta, StatPlots.

TOC

File Topic
01_constructors.ipynb Creating DataFrame and conversion
02_basicinfo.ipynb Getting summary information
03_missingvalues.ipynb Handling missing values
04_loadsave.ipynb Loading and saving DataFrames
05_columns.ipynb Working with columns of DataFrame
06_rows.ipynb Working with row of DataFrame
07_factors.ipynb Working with categorical data
08_joins.ipynb Joining DataFrames
09_reshaping.ipynb Reshaping DataFrames
10_transforms.ipynb Transforming DataFrames
11_performance.ipynb Performance tips
12_pitfalls.ipynb Possible pitfalls
13_extras.ipynb Additional interesting packages

Changelog:

Date Changes
2017-12-05 Initial release
2017-12-06 Added description of insert!, merge!, empty!, categorical!, delete!, DataFrames.index
2017-12-09 Added performance tips
2017-12-10 Added pitfalls
2017-12-18 Added additional worthwhile packages: FreqTables and DataFramesMeta
2017-12-29 Added description of filter and filter!
2017-12-31 Added description of conversion to Matrix
2018-04-06 Added example of extracting a row from a DataFrame
2018-04-21 Major update of whole tutorial
2018-05-01 Added byrow! example
2018-05-13 Added StatPlots package to extras
2018-05-23 Improved comments in sections 1 do 5 by Jane Herriman
2018-07-25 Update to 0.11.7 release
2018-08-25 Update to Julia 1.0 release: sections 1 to 10
2018-08-29 Update to Julia 1.0 release: sections 11, 12 and 13
2018-09-05 Update to Julia 1.0 release: FreqTables section
2018-09-10 Added CSVFiles section to chapter on load/save

Core functions summary

  1. Constructors: DataFrame
  2. Getting summary: size, nrow, ncol, length, describe, names, eltypes, head, tail
  3. Handling missing: missing (singleton instance of Missing), ismissing, Missings.T, skipmissing, coalesce, allowmissing, disallowmissing, allowmissing!, completecases, dropmissing, dropmissing!, disallowmissing, disallowmissing!
  4. Loading and saving: CSV (package), CSVFiles (package), JLD2 (package), CSV.read, CSV.write, save, @save (from JLD2), load, @load (from JLD2)
  5. Working with columns: rename, rename!, names!, hcat, insert!, DataFrames.hcat!, merge!, delete!, empty!, categorical!, DataFrames.index, permutedims!
  6. Working with rows: sort!, sort, issorted, append!, vcat, push!, view, filter, filter!, deleterows!, unique, nonunique, unique!
  7. Working with categorical: categorical, cut, isordered, ordered!, levels, unique, levels!, droplevels!, get, recode, recode!
  8. Joining: join
  9. Reshaping: stack, melt, stackdf, meltdf, unstack
  10. Transforming: groupby, vcat, by, aggregate, eachcol, eachrow, colwise
  11. Extras:
    • FreqTables: freqtable, prop
    • DataFramesMeta: @with, @where, @select, @transform, @orderby, @linq, by, based_on, byrow!
    • StatPlots: @df, plot, density, histogram,boxplot, violin

Changes in DataFrames master since last update of the tutorial

  • Upcoming: Tables.jl integration
  • Change of CSV.jl API
  • Change in handling ordered categorical values comparisons