In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "python apply (), map (), applymap () how to use", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "python apply (), map (), applymap () how to use it!"
In the data analysis of python, the custom operation of batch data can be easily realized by using apply (), map () and applymap (). Its usage is summarized as follows.
Function usage apply () is used to manipulate data in DataFrame by row or column. Map () is used to operate on every data in Series. Applymap () is used to manipulate every data in DataFrame. Example apply ()
Apply () is used to manipulate data in DataFrame by row or column.
Import pandas as pddata = [[110,120,110], [130,120,130]] columns= ['Chinese', 'mathematics', 'English'] df = pd.DataFrame (data=data, columns=columns) print (df) print ("=") print (lambda x: x.sum (), axis=1))
Where axis=1 stands for line alignment. An axis of 0 indicates a column alignment.
Map ()
Map () is used to manipulate every data in the Series.
Import pandas as pds1 = pd.Series ([11, 22, 33, 44, 55]) print (S1) print ("=") print (s1.map (lambda x: str (x) applymap
Applymap () is used for every data operation on DataFrame.
Manipulate every piece of data in DataFrame.
Take keeping two decimal places for each piece of data as an example:
Import pandas as pddata = [[110,120,110], [130,120,130]] columns= ['Chinese', 'mathematics', 'English'] df = pd.DataFrame (data=data, columns=columns) print (df) print ("=") print (df.applymap (lambda x:'% .2f'% x))
Thank you for your reading, the above is the "python apply (), map (), applymap () how to use" the content, after the study of this article, I believe you on python apply (), map (), applymap () how to use this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.