question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aggregate strings on a groupby operation

See original GitHub issue

Hi.

I need to group a dataframe and aggregate the strings as a list or a set. I have many string columns in the dataframe. How can I do that in vaex? This is the functionality I’m looking for:

d
   A       B
0  1    This
1  2      is
2  3       a
3  4  random
4  1  string
5  2       !

 d.groupby('A')['B'].apply(list)
A
1    [This, string]
2           [is, !]
3               [a]
4          [random]
dtype: object

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
kylegildecommented, Sep 15, 2021

Is this use case supported at this point? I don’t really see how to use AggregatorDescriptorMulti to do this task.

1reaction
JovanVeljanoskicommented, Nov 18, 2022

I understand but first step is creating the “dict” object right? Then the aggregation begins. Unless you already have data in that form (via pyarrow structs).

But please create a new issue on this, since it is going away from the original topic of this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Concatenate strings from several rows using Pandas groupby
The aggregation functionality provided by the agg() function allows multiple statistics to be calculated per group in one calculation. df.groupby(['name' ...
Read more >
Pandas: How to Concatenate Strings from Using GroupBy
This tutorial explains how to concatenate strings in a pandas DataFrame from using a GroupBy.
Read more >
Concatenate strings from several rows using Pandas groupby
Group the data using Dataframe.groupby() method whose attributes you need to concatenate. · Concatenate the string by using the join function and ...
Read more >
pandas.core.groupby.DataFrameGroupBy.agg
Aggregate using callable, string, dict, or list of string/callables ... If a function, must either work when passed a DataFrame or when passed...
Read more >
How to concatenate text as aggregation in a Pandas groupby
Aggregating values in a groupby is fairly easy. But did you know you can also concatenate strings as aggregation?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found