Skip to content

DOC: Groupby transform should mention that parameter can be a string #50029

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

Conversation

seanjedi
Copy link
Contributor

@seanjedi seanjedi commented Dec 2, 2022

…ould_mention_that_function_parameter_can_be_a_string_in_transfor
@rhshadrach
Copy link
Member

@seanjedi - thanks for the PR! Can you shorten the title (there is an edit button above) - being concise is best here.

@ramvikrams
Copy link
Contributor

ramvikrams commented Dec 3, 2022

@seanjedi can you add examples also,
For dataframegroupby you can add
grouped.transform("sum")
with it's output and similarly for SeriesGroupBy.transform()

@seanjedi seanjedi changed the title Seanjedi 49961 docs for groupby transform should mention that function parameter can be a string in transfor DOC: Groupby transform should mention that parameter can be a string Dec 3, 2022
…n_that_function_parameter_can_be_a_string_in_transfor' of https://github.com/seanjedi/pandas into SEANJEDI-49961_Docs_for_groupby_transform_should_mention_that_function_parameter_can_be_a_string_in_transfor
…ould_mention_that_function_parameter_can_be_a_string_in_transfor
@seanjedi
Copy link
Contributor Author

seanjedi commented Dec 3, 2022

@ramvikrams Responding to: #50029 (comment)
I believe that the docs for dataframegroupby and SeriesGroupBy transform utilizes the same location for their docs in the code, so it only requires the changes I made in that location to show up for both, as this is a template that get's used by those respective classes.
Would you want me to add what to expect for the output for this function in general? (I think it already does that?)
Or for dataframegroupby and SeriesGroupBy in particular?

Also, I have updated the code here for the example with grouped.transform("sum")
3b84281

@ramvikrams
Copy link
Contributor

ramvikrams commented Dec 4, 2022

@ramvikrams Responding to: #50029 (comment)
I believe that the docs for dataframegroupby and SeriesGroupBy transform utilizes the same location for their docs in the code, so it only requires the changes I made in that location to show up for both, as this is a template that get's used by those respective classes.
Would you want me to add what to expect for the output for this function in general? (I think it already does that?)
Or for dataframegroupby and SeriesGroupBy in particular?

Also, I have updated the code here for the example with grouped.transform("sum")
3b84281

I think we have to change the example also for Series it must be with pd.Series

@seanjedi
Copy link
Contributor Author

seanjedi commented Dec 4, 2022

@ramvikrams is this better?
b06287e

In DataFrameGroupBy.transform it should be pd.Dataframe = grouped.transform("sum")
and in SeriesGroupBy.transform it should be pd.Series = grouped.transform("sum")

@ramvikrams
Copy link
Contributor

@ramvikrams is this better?
b06287e

I think changing the example for series and then rewriting it completely because right now it's with pd.dataframe

@seanjedi
Copy link
Contributor Author

seanjedi commented Dec 4, 2022

@ramvikrams Sorry, I had to update my comment, for b06287e it should be updating the template, so that:
In DataFrameGroupBy.transform it should be pd.Dataframe = grouped.transform("sum")
and in SeriesGroupBy.transform it should be pd.Series = grouped.transform("sum")

Since %(klass)s seems to be updated in the docs to what is using it, so in DataFrameGroupBy it gets updated to Dataframe, and SeriesGroupBy it gets changed to Series

So I am a bit confused since that is what you wanted correct?
Or am I mistaking the request?
Care to elaborate a little bit more, as I am a bit confused by the ask sorry.

@ramvikrams
Copy link
Contributor

ramvikrams commented Dec 4, 2022

I am trying to say that this example

df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
                          'foo', 'bar'],
                   'B' : ['one', 'one', 'two', 'three',
                          'two', 'two'],
                   'C' : [1, 5, 5, 2, 5, 5],
                   'D' : [2.0, 5., 8., 1., 2., 9.]})

which is there in SeriesGroupBy.transform can you also change this it should be with pd.Series not dataframe, so can you rewrite this.

@seanjedi
Copy link
Contributor Author

seanjedi commented Dec 4, 2022

Ohh I see, I made an update here for that, hopefully, that fixes it, let me know where else I should do that change as well
f6c24f7

I see some other dataframes in the doc (IE line 467 and 484), but it is specifically saying when using transform with dataframes, so I am unsure if I should change it

@ramvikrams
Copy link
Contributor

@seanjedi can you change this for the series example

ser = pd.Series(
        [390.0, 350.0, 30.0, 20.0],
        index=["Falcon", "Falcon", "Parrot", "Parrot"],
        name="Max Speed",
    )

@seanjedi
Copy link
Contributor Author

seanjedi commented Dec 4, 2022

@ramvikrams I think this should resolve the ask that you had: 207abd6
Let me know if there is something else i should change

@seanjedi seanjedi requested review from rhshadrach and phofl and removed request for rhshadrach and phofl December 4, 2022 23:09
@mroeschke mroeschke added the Apply Apply, Aggregate, Transform, Map label Dec 6, 2022
…ould_mention_that_function_parameter_can_be_a_string_in_transfor
…n_that_function_parameter_can_be_a_string_in_transfor' of https://github.com/seanjedi/pandas into SEANJEDI-49961_Docs_for_groupby_transform_should_mention_that_function_parameter_can_be_a_string_in_transfor
@seanjedi seanjedi requested a review from rhshadrach December 6, 2022 01:43
@seanjedi seanjedi requested review from phofl and rhshadrach and removed request for rhshadrach and phofl December 6, 2022 20:54
…ould_mention_that_function_parameter_can_be_a_string_in_transfor
@seanjedi
Copy link
Contributor Author

seanjedi commented Dec 8, 2022

@rhshadrach Any other changes I should make?

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! One small request

@seanjedi seanjedi requested a review from rhshadrach December 8, 2022 22:15
…ould_mention_that_function_parameter_can_be_a_string_in_transfor
…ould_mention_that_function_parameter_can_be_a_string_in_transfor
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, ping on green.

@mroeschke mroeschke added this to the 2.0 milestone Dec 13, 2022
@mroeschke mroeschke merged commit 627d1b6 into pandas-dev:main Dec 13, 2022
@mroeschke
Copy link
Member

Thanks @seanjedi

@seanjedi
Copy link
Contributor Author

@mroeschke Thanks for merging it, and also sorry for the late reply, I am in grad school and this is finals week so I have been a bit busy today.
Glad I was able to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Docs Groupby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants