In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the knowledge points of python data analysis and mining". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the knowledge points of python data analysis and mining.
Introduction to python data Analysis 2.2, introduction to python 2.2.3, data structure
Python has four built-in data structures-list (list), tuple (tuple), dictionary (dictionary) and set (collection), which can be collectively referred to as containers.
(1) list / tuple
Functionally, the difference between a list and a tuple is that a list can be modified while a tuple cannot.
If you already have a list an and want to copy an and name it the variable b, then bounded rooma is not valid. At this time, b is just an alias (or reference) for a, and modifying b will also modify a. The correct replication method should be baked rooma [:]
Table 2-1 list / tuple related functions
Function function cmp (min b) compare two list / tuple elements min (a) return list / tuple element minimum value len (a) list / number of tuple elements sum (a) summation of elements in list / tuple max (a) return list / tuple element maximum value sorted (a) sort the elements of the list in ascending order
Table 2-2 list-related methods
Function function a.append (1) add 1 to the end of list an a.count (1) count the number of occurrences of element 1 in list an a.extend ([1,2]) append the contents of the list [1,2] to the end of list an a.index (1) find the index position a.insert (2) of the first 1 in list a 1) insert 1 into table a with index 2 a.pop (1) remove the element in list a with index 1 (2) dictionary dict ([['today',20], [' tomorrow',30]]) # is also equivalent to {'today':20,' tomorrow':30} dict.fromkeys (['today',' tomorrow'], 20) # is equivalent to {'today':20,' tomorrow':20} (3) collection
Python has built-in the data structure of set, which is basically consistent with the mathematical concept of set. The difference between it and list is as follows: 1. Its elements are unrepeatable and unordered. It does not support indexing. Typically we create a collection through curly braces {} or the set () function.
S = (1, 2, 2, 3} # Note 2 will automatically remove the weight, resulting in {1, 2, 3} s = set ([1, 2, 2, 3]) # similarly, it converts the list into a set, resulting in {1, 2, 3}
Because of the particularity of the set (especially the disorder), the set has some special operations.
A = t | Union of s # t and s b = t & s # t and s intersection c = t-s # difference set (term in t, but not in s) d = t ^ s # symmetric difference set (term in t or s, but not both) (4) functional programming
In python, functional programming is mainly composed of several functions: lambda (), map (), reduces (), filter ().
F=lambda x: Xray 2 # defines the function f (x) = x+2g=lambda XMagi y: Xray y # defines the function g (x Magi y) = x Magi a = [1 Magi 2 Magi 3] b=map (lambda x: Xerox 2 Magi a) b=list (b) # the result is [3Jing 4 Magi 5]
B=list (b) is required in 3.x, but not in 2.x, because in 3.x, the map function simply creates a command container to run and returns results only when other functions call it.
The reduce () function is used for recursive computation
Reduce (lambda x ~ (1): X ~ (1)) is equivalent to s=1for i in range (1 ~ ()): s=s*i
The above command can be run directly in 2.x. In 3.x, the reduce function has been removed from the global namespace, and it is placed in the fuctools library. If you need to use it, you need to use from fuctools import reduce.
The filter () function is a filter
B=filter (lambda x: X > 5 and x
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.