+ 1

Pandas. Custom names for function values

I have this code and it returns a dataframe with name and mean marks in ascending order. p=mark_table.mean(axis=1) p=p.sort_values() Upon running, the name part has a column heading which already presented in the dataframe.but after i using the mean() there is no column name on the top of the mean values.Its just empty. My question is that can i name the mean column as we do in SQL like below?👇 Select max(nums) as maximum Thank you for your Time!

12th Jan 2022, 3:44 PM
sid
sid - avatar
5 ответов
+ 1
Could you show a snippet of the resulting data frame and describe where you want to add a name?
27th Jan 2022, 1:38 PM
Velme
Velme - avatar
0
I want to print thee values in mean() with a custom column name.(currently blank)
27th Jan 2022, 1:50 PM
sid
sid - avatar
0
Velme Check the screenshot https://ibb.co/YyHpdwC
27th Jan 2022, 1:51 PM
sid
sid - avatar
0
Try p.columns = ['name', 'custom name']
27th Jan 2022, 2:22 PM
Velme
Velme - avatar
0
I guess p.columns[1] = 'custom name' should also work
27th Jan 2022, 2:25 PM
Velme
Velme - avatar