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

Column Order Question #219

Open
Amnesiac9 opened this issue Aug 7, 2023 · 0 comments
Open

Column Order Question #219

Amnesiac9 opened this issue Aug 7, 2023 · 0 comments

Comments

@Amnesiac9
Copy link

Amnesiac9 commented Aug 7, 2023

Hello,

When using GroupBy() and then Aggregation() the column order that outputs is not as I'd expect coming from Pandas.

Is there a reason the order is not preserved or the new aggregated columns are not simply appended in the order they are entered?

Gota seems to append columns in alphabetical order, is there a reason for that extra sorting step the user doesn't explicitly call?

The code below will not output the columns in the order they are entered into the []string

func cleanDataframe(df *dataframe.DataFrame) (*dataframe.DataFrame, error) {

	group := *df.GroupBy("CustomerId", "ShortSku")
	if group.Err != nil {
		return nil, group.Err
	}

	agg_df := group.Aggregation([]dataframe.AggregationType{
		dataframe.Aggregation_SUM,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_FIRST,
		dataframe.Aggregation_SUM,
		dataframe.Aggregation_COUNT},
		[]string{
			"Quantity",
			"CustomerName",
			"Address1",
			"Address2",
			"City",
			"State",
			"Zip",
			"Country",
			"Phone",
			"Email",
			"ClubEnrollment",
			"AccountType",
			"Spend",
			"OrderCount"})
	if agg_df.Err != nil {
		return nil, agg_df.Err
	}

	return &agg_df, nil
}
@Amnesiac9 Amnesiac9 changed the title Column Orderquestion Column Order Question Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant