to determine if there is no data point
Ser1 = Series ([5,4,3,2,-1],index=[' A ', ' B ', ' C ', ' d ', ' e '])
print (ser1)
output result:
a 5
b 4
C 3
D 2
e -1
Retrieving data by index
Print (ser1[' C '])
output result:
3
If you have some data in a Python dictionary, you can create a series from that data by passing the dictionaryCreate a series from a dictionary
Sdata = {}
sdata[' a '] = 5
sdata[' c '] = ten
sdata[' B '] = 4
sdata[' d '] =-2
ser2 = Series (sdata)
print (ser
specified axis.
That is, to delete the meaning of a Series element or a row (column) of DataFrame.drop(labels, axis=0)Method:
>>> serd 4.5b 7.2a -5.3c 3.6dtype: float64>>> df Ohio Texas Californiaa 0 1 2c 3 4 5d 6 7 8[3 rows x 3 columns]>>> ser.drop('c')d 4.5b 7.2a -5.3dtype: float64>>> df.drop('a') Ohio Texas Californiac
feasible. Also note that when used reindex(index,method=‘**‘) , index must be monotonous, otherwise it will be thrown ValueError: Must be monotonic for forward fill , such as the last call in the previous example, if index=[‘a‘,‘b‘,‘d‘,‘c‘] the use of the words will not.Delete an item on a specified axisThat is, delete the elements of a Series or the meaning of a row (column) of DataFrame, by means of the object .drop(labels, axis=0) :>>> serd 4.5b 7.2a -5.3c 3.6dtype:float64>>> df
-assign the value of the # line, you can use the row name or the number of rows to choose Print frame1.ix[' two '] #为列赋值, if it is a series, the index can be specified after the exact value frame1[' d '] = Series ([100,200,300],index = [' Two ', ' one ', ' three ']) print frame1# Delete column with del frame1[' d '] #警告: A series view is selected by column name, is not a copy and can be copied using the series copy methodAnother common structure is a nested dictionary, which is a dictionary of d
1. Search Associative array keysIf a specified key is found in an array, the function array_key_exists () returns TRUE, otherwise it returns false. Its
The form is as follows:Boolean array_key_exists (mixed key, array array)
The following example searches for the Ohio in the array key, and if found, will output the education information for the state to join the U.S. federal Government:$state ["Delaware"]= "December 7,1787";$state ["Pennsylvania"]=
A virtual electronic map of highways in Ohio uses colors to mark the risk factor of a crash. "Green indicates that the probability of a crash is very small. Yellow indicates that the probability of a crash is moderate. Red indicates that a collision of a vehicle is very likely to occur in this region during this time period ." Even high-tech devices such as satellites that monitor highway conditions in real time do not have the ability to pr
Statistical frequency of the occurrence of array elementsThe Array_count_values () function returns an array containing the associated key/value pairs. In the form of ZArray array_count_values (array array)Each of these keys represents a value in Input_array, and the corresponding value indicates that the key appears in Input_array (as a value)The frequency. Examples are as follows:$states = Array ("Ohio", "Iowa", "Arizona", "Iowa", "
==========Key ()Mixed key (array Input_array)The key () function returns the Input_array element at the current pointer position.#example4
Copy Code code as follows:
$capitals = Array ("Ohio" => "Columbus", "Towa" => "Des Moines", "Arizona" => "Phoenix");
echo "while ($key = key ($capitals)) {
echo $key. " Next ($capitals);
Each key () call does not push the pointer. To do this, use the next () function
}
?>
Show Resul
result:
The number is zero.
The number is one.
The number is two.
========== The following is a function introduction ============Key ()Mixed key (array input_array)The key () function returns the key element at the current pointer position in input_array.# Example4
The code is as follows:
$ Capitals = array ("Ohio" => "Columbus", "Towa" => "Des Moines", "Arizona" => "Phoenix ");Echo"
Can you name the capitals of these states?";
While ($ key = ke
addition to 3 seconds, 30 seconds, 10 seconds, 5 seconds and 1 seconds are also very common.
Shielding users
Shielding AreaHow to shield the area is also a difficult problem, because you have to compare the area of the tweet and the blocked area. The problem is that when users block "Ohio Columbus", the publisher's area is Columbus. Although people may clearly distinguish between these two are the same area, but in the computer, "
(array input_array)The key () function returns the key element at the current pointer position in input_array.# Example4 The code is as follows:
$ Capitals = array ("Ohio" => "Columbus", "Towa" => "Des Moines", "Arizona" => "Phoenix ");Echo"
Can you name the capitals of these states?";
While ($ key = key ($ capitals )){
Echo $ key ."
";
Next ($ capitals );
// Each key () call does not push the pointer. Use the next () function.
}
?>
Display result:
pointer position in Input_array.#example4Copy the Code code as follows:
$capitals = Array ("Ohio" = "Columbus", "towa" = "Des Moines", "Arizona" and "Phoenix");echo "
Can you name the capitals of these states?";
while ($key = key ($capitals)) {
echo $key. "
";
Next ($capitals);
Each key () call does not push the pointer. To do this, use the next () function
}
?>
Show Results:
Can you name the capitals of these states?
2 DataFrameA: Dataframe automatically indexed by passing in a list of equal lengths1data={' State':['Ohio','Ohio','Ohio','Nevada','Nevada'],2 ' Year':[ -,2001,2002,2001,2002],3 'Pop':[1.5,1.7,3.6,2.1,2.9]}4Frame=dataframe (data)B: Specify sequential sequence (previously sorted by default)1 DataFrame (data,columns=['year','State',' pop'])C: When the d
Pandas has two data structures, one is series and the other is DataframeFrom matplotlib import Pyplot as PltImport NumPy as NPImport Pandas as PDFrom NumPy import nan as NAFrom pandas import DataFrame, Series%matplotlib InlineSeries is essentially a one-dimensional array# Series# arrays are associative to dictionaries, but can use non-numeric subscript indexes.can be accessed directly through the indexobj = Series ([4, 7,-5, 3])Obj0 -53 3dtype:int64Obj2 = Series ([4, 7, -5, 3], index=[' d '
current pointer position in Input_array.#example4
$capitals = Array ("Ohio" = "Columbus", "towa" = "Des Moines", "Arizona" and "Phoenix");
echo "
while ($key = key ($capitals)) {
echo $key. "
Next ($capitals);
Each key () call does not push the pointer. To do this, use the next () function
}
?>
Show Results:Can you name the capitals of these states?OhioTowaArizonaReset ()Mixed reset (array Input_array)T
designed to simplify the development of dynamic WEB programs. See http://www.prototypejs.org/. In the above code: Event.observe is equivalent to attachevent in IE, which is used to register the event handler function. This is registered with the Window.onload and Country.onchange event handlers. $ () is an alias for document.getElementById (). $F () takes out the current value of the element in the form. Show () and hide () are methods that are added on HTML elements. Many methods are extended
in input_array.# Example4Copy codeThe Code is as follows:$ Capitals = array ("Ohio" => "Columbus", "Towa" => "Des Moines", "Arizona" => "Phoenix ");Echo "While ($ key = key ($ capitals )){Echo $ key. "Next ($ capitals );// Each key () call does not push the pointer. Use the next () function.}?>Display result:Can you name the capitals of these states?OhioTowaArizonaReset ()Mixed reset (array input_array)The reset () function is used to set the input_a
" => "zero", "1" => "one", "2" => "two ");For ($ I = 0; $ I $ Str = $ arr [$ I];Echo "the number is $ str.";}?>
Display result:
The number is zero.The number is one.The number is two.
II. Introduction to array pointer operation functions
Key ()
Mixed key (array input_array)
The key () function returns the key element at the current pointer position in input_array.
# Example4
The code is as follows:
$ Capitals = array ("Ohio" => "Columbus", "Towa" =>
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.