Sep-18-2021, 07:42 AM
(Sep-18-2021, 07:26 AM)DPaul Wrote: Except when i print the resultNo only 1 are index use
of the subtotal after grouping, it displays 0,1... on top,
are these indexes?
df.columns
to see,have to reset the index.>>> df = Qdf.groupby([0]).sum() >>> df 1 0 AF-10 1988.10 AF-20 90.00 BA-40 2850.00 BA-50 150.00 BO-30 16514.61 BR-10 528.35 >>> df.columns Int64Index([1], dtype='int64') >>> >>> df = df.reset_index() >>> df.columns Int64Index([0, 1], dtype='int64') >>> df 0 1 0 AF-10 1988.10 1 AF-20 90.00 2 BA-40 2850.00 3 BA-50 150.00 4 BO-30 16514.61 5 BR-10 528.35 >>> df[0] 0 AF-10 1 AF-20 2 BA-40 3 BA-50 4 BO-30 5 BR-10 Name: 0, dtype: object