I have the following code...which for some reason results in the 'key' column disappearing. I have also noticed other times when the key column seems to 'randomly' disappear. I am trying to isolate the cases, this is one.
I am usinng 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:
G N
1 b 2
2 b 3
The second print groupByObj.get_group('b') results in:
N
1 2
2 3
Why does the 'key' column ('G') disappear after running groupByObj.sum()