Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation on empty groups fails because of LoadMaps #156

Open
danielpcox opened this issue Jun 30, 2021 · 1 comment
Open

Aggregation on empty groups fails because of LoadMaps #156

danielpcox opened this issue Jun 30, 2021 · 1 comment
Labels

Comments

@danielpcox
Copy link

danielpcox commented Jun 30, 2021

If I do an Aggregate_SUM on a Group from a DataFrame with no rows, instead of returning 0 like I would expect, it fails at the top of LoadMaps. This is because Aggregation calls LoadMaps at the end to build the resulting DataFrame, but an empty map slice is an error for LoadMaps.

In this case, I think it would be best for Aggregate to never call LoadMaps with an empty map slice, but rather insert the zero value appropriate for whatever AggregationType the user picked for all empty groups.

To reproduce:

import(
	"fmt"
	"github.com/go-gota/gota/dataframe"
	"github.com/go-gota/gota/series"
)

df := dataframe.New(
	series.New([]string{"e", "Pi", "Phi", "Sqrt2", "Ln2"}, series.String, "Strings"),
	series.New([]float64{2.718, 3.142, 1.618, 1.414, 0.693}, series.Float, "Floats"),
)
agg := df.
	Filter(dataframe.F{0, "Strings", "==", "DNE"}).
	GroupBy("Strings").
	Aggregation([]dataframe.AggregationType{dataframe.Aggregation_SUM}, []string{"Floats"})

fmt.Println(agg)

// DataFrame error: load maps: empty array
@Bl4cksunLtd
Copy link

just been bitten by this bug, anyone working on a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants