Reputation: 2134
I have a dataframe like below
Mode Time
Air 2
Sea 4
Air 5
Sea 6
So I want to have the output as
Mode Time
Air 3.5
Sea 5
The output should contain two columns Mode and the Time.
With my Code I dont see the columns coming. Below is my code:
mean_remaining_shipment_time_mode=training_data.groupby('mode')['Time'].mean()
The output of this is:
Series: mode
Air 3.813711
Ocean 14.670060
Parcel 3.036790
Truck 3.097268
Name: remainingShiptime, dtype: float64
Upvotes: 1
Views: 679
Reputation: 95948
Don't select the column:
>>> df1.groupby('Mode').mean()
Time
Mode
Air 3.5
Sea 5.0
>>>
>>> df1.groupby('Mode').mean().reset_index()
Mode Time
0 Air 3.5
1 Sea 5.0
>>>
Upvotes: 2