I have the following code ... which for some reason causes the key column to disappear. I also noticed that once a key column "accidentally" disappears. I am trying to isolate cases, this is one.
I am using pandas version 0.20.1
DF = pd.DataFrame([['a', 1], ['b', 2], ['b', 3]], columns = ['G', 'N']) groupByObj = DF.groupby('G') print groupByObj.get_group('b') groupByObj.sum() print groupByObj.get_group('b')
The first print groupByObj.get_group('b') results in:
GN 1 b 2 2 b 3
The second print groupByObj.get_group('b') results in:
N 1 2 2 3
Why does the column "key" ("G") disappear after running groupByObj.sum()
source share