Gmousse / dataframe-js

No Maintenance Intended
https://gmousse.gitbooks.io/dataframe-js/
MIT License
460 stars 38 forks source link

Converting grouped to DataFrame #75

Closed geyang closed 4 years ago

geyang commented 5 years ago

currently there is not a good way to convert a grouped DataFrame to a DataFrame.

The GroupedDataFrame class is also missing toDict method.

Gmousse commented 5 years ago

Hi @episodeyang,

Can you give me a usage example about converting a grouped DataFrame into a DataFrame ?

It could be interesting in order to have a DataFrame having multiple DataFrames in each row, but I don't know if it's not too tricky and really useful.

geyang commented 5 years ago

Here I have a data frame with keys:

["id", "metricFiles", "Args.start_seed", "Args.lr", "Args.weight_decay"]

I want to average those which have the same learning rate and weight decay parameters.

Because the grouped data frame does not have toDict methods, I need to declare a new one.

  const grouped = sorted.groupBy(...groupKeys)
      .aggregate(group => group.select(...intersect(aggKeys, allKeys)).toDict());

  df = new DataFrame({
    ...grouped.select(...groupKeys).toDict(),
    ...new DataFrame(grouped.select('aggregation').toDict().aggregation || []).toDict()
  });

  const expList = df.toCollection();
  console.log(expList);
Gmousse commented 5 years ago

Hi @episodeyang,

In understand the need. I will see to implement a solution.

Gmousse commented 4 years ago

Closed due to inactivity. We will repoen it if necessary.