Skip to content

Commit

Permalink
Merge pull request #147 from go-gota/dev
Browse files Browse the repository at this point in the history
Release v0.11.0
  • Loading branch information
chrmang committed Jun 26, 2021
2 parents d8f1f57 + 43d76ea commit 54b035e
Show file tree
Hide file tree
Showing 13 changed files with 1,345 additions and 140 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# IntelliJ
.idea/
*.iml

# vscode
.vscode/
*.code-workspace
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
language: go
go: master
script: go test -v ./dataframe ./series
before_script:
- echo 'Checking code quality issues.'
- go vet ./...
- echo 'Checking that gofmt was used.'
- diff -u <(echo -n) <(gofmt -d .)
- echo 'Checking tidiness of go mod.'
- go mod tidy
- test -z "$(git status --porcelain)"
script:
- echo 'Running tests.'
- go test -v ./...
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.11.0] - 2021-04-25
### Added
- Rolling window Mean and StdDev
- GroupBy and Aggregate
- Numeric column index
- Read HTML tables
- extra checks for TravisCI
- Combining filters with AND
- User-defined filters
- Concatination of Dataframes

### Changed
- Make fixColnames faster
- Use Go 1.16
- Update dependencies

### Fixed
- Linter issues
- Failing tests

## [0.10.1] - 2019-11-08
### Fixed
- LoadRecords printing type debug information
Expand Down
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,80 @@ column "B" is greater than 4:
fil := df.Filter(
dataframe.F{"A", series.Eq, "a"},
dataframe.F{"B", series.Greater, 4},
)

filAlt := df.FilterAggregation(
dataframe.Or,
dataframe.F{"A", series.Eq, "a"},
dataframe.F{"B", series.Greater, 4},
)
```

Filters inside Filter are combined as OR operations, alternatively we can use `df.FilterAggragation` with `dataframe.Or`.

If we want to combine filters with AND operations, we can use `df.FilterAggregation` with `dataframe.And`.

```go
fil := df.FilterAggregation(
dataframe.And,
dataframe.F{"A", series.Eq, "a"},
dataframe.F{"D", series.Eq, true},
)
```

To combine AND and OR operations, we can use chaining of filters.

```go
// combine filters with OR
fil := df.Filter(
dataframe.F{"A", series.Eq, "a"},
dataframe.F{"B", series.Greater, 4},
)
// apply AND for fil and fil2
fil2 := fil.Filter(
dataframe.F{"D", series.Eq, true},
)
```

Filters inside Filter are combined as OR operations whereas if we chain
Filter methods, they will behave as AND.
Filtering is based on predefined comparison operators:
* `series.Eq`
* `series.Neq`
* `series.Greater`
* `series.GreaterEq`
* `series.Less`
* `series.LessEq`
* `series.In`

However, if these filter operations are not sufficient, we can use user-defined comparators.
We use `series.CompFunc` and a user-defined function with the signature `func(series.Element) bool` to provide user-defined filters to `df.Filter` and `df.FilterAggregation`.

```go
hasPrefix := func(prefix string) func(el series.Element) bool {
return func (el series.Element) bool {
if el.Type() == String {
if val, ok := el.Val().(string); ok {
return strings.HasPrefix(val, prefix)
}
}
return false
}
}

fil := df.Filter(
dataframe.F{"A", series.CompFunc, hasPrefix("aa")},
)
```

This example filters rows based on whether they have a cell value starting with `"aa"` in column `"A"`.

#### GroupBy && Aggregation

GroupBy && Aggregation

```go
groups := df.GroupBy("key1", "key2") // Group by column "key1", and column "key2"
aggre := groups.Aggregation([]AggregationType{Aggregation_MAX, Aggregation_MIN}, []string{"values", "values2"}) // Maximum value in column "values", Minimum value in column "values2"
```

#### Arrange

Expand Down
Loading

0 comments on commit 54b035e

Please sign in to comment.