Discover python convert dataframe to list, include the articles, news, trends, analysis and practical advice about python convert dataframe to list on alibabacloud.com
. Collection (SET)
A collection is a mathematical concept that is created with set ()Set.add (), set.update.set.remove, add update Delete, = can do set subtractionSet.discard and Set.remove difference is that if the deleted element is not in the collection, discard does not complain, remove error| Represents union Representation intersection-representation difference set ^ difference set
3. Listing (list)
A li
an integer, float (x) converts x to a floating-point number complex (real [, Imag]) creates a complex number str (x) to convert the object x to a string repr (x) to convert the object x to the expression string eval (St R) is used to calculate a valid Python expression in a string and returns an object tuple (s) converts the sequence s to a tuple
The list in python is similar to the variable array (arraylist) in C # and used for sequential storage structure.
Create listSample_list = ['A', 1, ('A', 'B')]
Python list operationsSample_list = ['A', 'B', 0, 1, 3]
Obtain a value in the list.Value_start = sample_list [0]End_value = sample_list [-1]
Delete the first v
A Daniel Niklaus Wirth once had a book, called "Algorithms+data Structures=programs", translated over the algorithm + data structure = program. This article is about the three types of data structures built into Python----lists, tuples, and dictionaries. List 列表Is the data structure that handles a set of ordered items, that is, you can store a sequence of items in a
can be filtered out: [python] view plain copy print?
>>> [x*x for x in range (1, one ) if x2 = = 0]
[4, +, +,-+ ]
>>>
Of course, you can use a two-layer loop to generate a full array: [python] view plain copy print?
>>>form in "ABCD" fornin ' XYZ ']
[' AX ', ' AY ', ' AZ ', ' BX ', ' by ', ' BZ ', ' CX ', ' CY ', ' CZ ', ' DX ', ' DY ', ' DZ ' ']
This article mainly introduces the list Generator and Generator learning tutorial in Python. The Generator in Python is more powerful than the list Generator. For more information, see
List GeneratorThat is, the method for creating a lis
What is a list?A list consists of a series of elements arranged in a particular order. The list looks like this: [1,2,3,4,1]. In a list, you can consist of 0 or more elements, separated by commas, with the same value element allowing multiple occurrencesCreate a list using [
#python List‘‘‘There are many ways to create a list:1. Create an empty list:[with one square bracket]2. Use a pair of brackets, with ', ' to separate the elements inside: [A, B, C], [a]3.Using a list comprehension:[x for x in iterable]4.Using the Type constructor:list () or
Yesterday is the first day of the week, a brief review of yesterday's study of things, in a re-look at the previous blog it.Well, then today's collection began to learn, I only learning not to enter the time will open my magical world, under normal circumstances, he should be hidden in my body.List: The Bible probably means: The list is Python's labor, Python is beginner's mind mainland.I do not know where
Traverse the entire list for loopExample: lists=[' A ', ' B ', ' C ', ' D ']For list in lists: Print (list)Result: ABCD
list is a temporary variable, the for loop takes the elements in the list lists in turn, and executes the code below the indented section
The
Demonstrate the list generative usage in Python using code instances.
1 sq list
If you want to create a list containing 1 to 10 square meters, you can do this:
squares = []for x in range(10): squares.append(x**2)
This is a simple example, but you can use the list generator
Beginners often encounter the problem of removing repeated elements from the list. This problem may be required for loops in other languages, but it is very simple to use in python. the following article describes how to deduplicate the python list and how to expand it, for more information, see.
Preface
Python contains six built-in sequences:List, tuples, strings, Unicode strings, buffer objects, xrange objects
This article mainly discusses the two most common types: List and tuples.
URL: http://www.cnblogs.com/archimedes/p/python-list-tuple.html.
The main difference between a lis
Python uses the list or dict field mode to read files,
Preface
Python is a powerful tool for processing text data. It is extremely simple to read, split, filter, and convert, so developers do not need to consider complicated stream file processing processes (compared with JAVA, hey ). Some complex text data processing
storagebelongs to an immutable sequence typeFixed-length, heterogeneous, arbitrary nestingObject reference ArrayBy separating some values with commas, a tuple is created automatically:
Copy the Code code as follows:
>>>
(1, 2, 3)
>>> ()
()
>>> 42
42
>>> 42,
(42,)
>>> (42,)
(42,)
Tuples are also (mostly) enclosed in parentheses, and empty tuples can be represented by two parentheses that do not contain content:
Tuple function
The function of the tuple function is basically the same as the
operation2.list usageAdd append (e) to the list, append to the bottomRemove Pop (index i) from the list to delete the element that contains the indexRemoving the Remove (e) method from the list, deleting the element EHigh-level usage of the list list.extend (LIST2) or a set
Resources:1. Basic Python Tutorial2. http://www.runoob.com/python/python-lists.html3. http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000Built-in functions for common operations lists:
Serial Number
function
1
CMP (List1, List2)Compare two elements of a lis
','Master','Secret']>>> ["%s=%s"% (k, params[k]) forKinchParams.keys ()] 3['Server=mpilgrim','Uid=sa','Database=master','Pwd=secret']>>> ["%s=%s"% (k, params[k]) for K in Params.keys () if K.startswith (' s ')][' Server=mpilgrim ']1An example of a simple list map. The mapping expression is exactly the element itself, so this list map returns the intact copy of the list
One, list operation mind Map
Two, list operation detailed explanation
1, definition and initialization
LST = list () #使用list定义一个空列表
LST = [] #使用 [] Define an empty list
LST = [1,2,3] #使用 [] Define and initialize the list
LST =
_ hash () _ method can be used as a key value
2. set)
A set is a mathematical concept created using set ().Set. add (), set. update. set. remove, add update and delete,-= can be used for set subtraction.The difference between set. discard and set. remove is that if the deleted element is not in the set, discard does not report an error and remove returns an error.| Indicates Union indicates intersection-indicates difference set ^ difference diversity
3. li
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.