dfutils

package module
v0.0.0-...-d66327a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Overview

The collection of utilities to work with QFrame implementation of the data frames in GO language. It is aimed to provide implementation of functions missed in original QFrame but which is necessary for easy data manipulation using data frames.

Installation

go get github.com/yaricom/dfutils

Joining Data Frames

The data frames join operations is necessary for complex data manipulation routines involving multistage data processing.

Left Join

The left join allows joining of two data frames by keys in the specific column. It is similar to the SQL LEFT JOIN function. All rows from the left data frame will remain and matched columns from the right data frame will be added.

Example

The left join of two data frames can be done as following:

    import (
        "github.com/tobgu/qframe"
        "github.com/yaricom/dfutils"
        "strings"
    )

    leftDF := qframe.ReadCSV(strings.NewReader(leftData))
    rightDF := qframe.ReadCSV(strings.NewReader(rightDate))
    
    colNames := map[string]string{"C": "E"}
    joinedDF, err := dfutils.LeftJoin("Category", &leftDF, &rightDF, colNames)
Left Table
Category(s) Subcategory(s) A(i) B(i) C(i)
cat1 sub1 1 101 201
cat1 sub2 2 102 202
cat1 sub3 3 103 203
cat1 sub4 4 104 204
cat2 sub5 5 105 205
cat2 sub6 6 106 206
cat2 sub7 7 107 207
cat2 sub8 8 108 208
cat2 sub9 9 109 209
Right Table
Category(s) C(i)
cat1 1000
cat2 2000
cat3 3000
Join Table
Category(s) Subcategory(s) A(i) B(i) C(i) E(i)
cat1 sub1 1 101 201 1000
cat1 sub2 2 102 202 1000
cat1 sub3 3 103 203 1000
cat1 sub4 4 104 204 1000
cat2 sub5 5 105 205 2000
cat2 sub6 6 106 206 2000
cat2 sub7 7 107 207 2000
cat2 sub8 8 108 208 2000
cat2 sub9 9 109 209 2000

Utilities

Multiple utilities also provided.

Keep Columns

Allows keeping only a few columns and remove other ones. It is handy when you have many columns and want to keep only a few:

	df := qframe.New(map[string]types.DataSlice{
		"A": make([]float64, 10), "B": make([]float64, 10), "C": make([]float64, 10), "D": make([]float64, 10),
	})

	// invoke function
	resDF := dfutils.KeepColumns(&df, "A")

Credits

  • The QFrame (Data Frames for GO language) created and maintained by Tobias Gustafsson, see: QFrame

This source code maintained and managed by Iaroslav Omelianenko

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainedIn

func ContainedIn(value string, list []string) bool

ContainedIn checks if a value in a list of a strings

func KeepColumns

func KeepColumns(df *qframe.QFrame, cols ...string) qframe.QFrame

KeepColumns is keep only specified columns in the provided data frame. All other columns will be dropped. It is handy when many columns should be dropped at once by keeping only a few.

func LeftJoin

func LeftJoin(col string, left, right *qframe.QFrame, rNamesMap map[string]string) (*qframe.QFrame, error)

LeftJoin is to do left join of the two data frames using values from the col column as a keys. The provided names map allows to rename columns of the right tables during join.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址