我有以下代碼:熊貓GROUPBY存儲在一個新的數據幀
import pandas as pd
df1 = pd.DataFrame({'Counterparty':['Bank','Bank','GSE','PSE'],
'Sub Cat':['Tier1','Small','Small', 'Small'],
'Location':['US','US','UK','UK'],
'Amount':[50, 55, 65, 55],
'Amount1':[1,2,3,4]})
df2=df1.groupby(['Counterparty','Location'])[['Amount']].sum()
df2.dtypes
df1.dtypes
的DF2數據幀沒有,我彙總了各列(交易對手和地點)。任何想法,爲什麼是這種情況?金額和金額1都是數字字段。我只是想從指數跨越Amount1
http://pandas.pydata.org/pandas-docs/stable/groupby.html#automatic-exclusion-of-nuisance-columns –