A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/46369 below:

SeriesGroupBy.apply results in wrong name when there is a single group · Issue #46369 · pandas-dev/pandas · GitHub

df = pd.DataFrame({'a': [0], 'b': [1]})
ser = df['b'].rename(None)
print(ser.groupby(df['a']).apply(lambda x: x))

df = pd.DataFrame({'a': [0, 1], 'b': [1, 2]})
ser = df['b'].rename(None)
print(ser.groupby(df['a']).apply(lambda x: x))

produces

0    1
Name: 0, dtype: int64
0    1
1    2
dtype: int64

In the first case, the name attribute on the resulting Series is set as 0, the group. In the second case, the two groups have different names and so the correct name attribute of None is on the result. The name attribute should be None in the first case as well.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4