Python's Operator.itemgetter (' click ') is used to define the function that gets the ' click ' entry

Source: Internet
Author: User

b = Operator.itemgetter (1) defines function B, which is used to get the value of the 1th field passed into the list

You can use B as the key for the sort function. As the basis for sorting.


Adn_app_data_map is a dictionary.


For key, App_arr in Adn_app_data_map.items ():

App_arr.sort (Key=operator.itemgetter (' click '), Reverse=true)
App_arr = App_arr[:3]
Keys = Key.split (' # ')
Category = Keys[0]
ad_network_id = keys[1]
ad_id = keys[2]
For apps in App_arr:
dimension_values = category + ' # ' + app[' app_id ' + ' # ' + ad_network_id + ' # ' + ad_id
Record = app[' campaign_id ' + ', ' + Adn_ad_category_app_report + ', ' + dimension_values + ', ' + app[' impression '] + \
', ' + str (app[' click ') + ', ' + app[' impression_cost '] + ', ' + app[' click_cost '] + ' \ n '
Csv.writelines (Record)

Python's Operator.itemgetter (' click ') is used to define the function that gets the ' click ' entry

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.