Click on the above “Python Home of sharing ”, Focus on
reply “ resources ” You can get a gift Python Learning materials
today
Japan
chicken
soup
Dew from tonight white , The moon is my hometown .
Hello everyone , I'm Pippi .
A few days ago Python The strongest King exchange group 【 Chen Ma Chen Cheng 】 Asked a question Pandas
Issues dealt with , As shown in the figure below .
The raw data are as follows :
df = pd.DataFrame({
'student_id': ['S001','S002','S003'],
'marks': [[88,89,90],[78,81,60],[84,83,91]]})
df
The expected results are shown in the following figure :
here 【 Mr. Yu Liang 】 Give a feasible code , We met later , You can modify it accordingly , Yield twice the result with half the effort , The code is as follows :
df['dmean'] = df['marks'].map(lambda x: np.mean(x))
After running , The result is what you want .
later 【 Mr. Yu Liang 】 Another optimized code is given as follows :
df['dmean'] = df['marks'].map(np.mean)
perhaps
df['dmean'] = df['marks'].apply(np.mean)
After running , The result is what you want .
It perfectly solves the problem of fans !
Hello everyone , I'm Pippi . This article mainly reviews the use of Pandas
Dealing with data , In this paper, the specific analysis and code implementation are given , There are two ways , Help the fans solve the problem smoothly .
Finally, thank the fans 【 Chen Ma Chen Cheng 】 put questions to , thank 【 Luna 】、【 Mr. Yu Liang 】 Given the idea and code analysis , thank 【dcpeng】 And others participate in learning and communication .
friends , Practice it quickly ! If in the process of learning , Any problems encountered , Welcome to add my friend , I'll pull you in Python The learning exchange group discusses learning together .
------------------- End -------------------
Excellent articles in the past are recommended :
An article will take you through Pandas mapping API
Netease cloud music popular works name and link capture (html5lib piece )
Netease cloud music popular works name and link capture (pyquery piece )
Netease cloud music popular works name and link capture (bs4 piece )
Welcome to give the thumbs-up , Leaving a message. , forward , Reprint , Thank you for your company and support
Want to join Python Learning group, please reply in the background 【 Enter into Group 】
All rivers and mountains are always in love , Order one 【 Looking at 】 OK?
1、開運算先腐蝕後膨脹的操作稱為開運算The role of
Take the answer : The code of