As a long-winded blogger, or to say Diansha, if you do not want to learn, drag and drop directly to the final, he found eggs, then 3 seconds
I do, there is a small goal, is to put technology like the article, write interesting
Programming it, what is the hardest?
I voted for the entry
In fact, a person programmed into the door is the hardest
And the dream eraser chiefs, in doing this
(it plainly, is to write the article profound, but also pretended chiefs, tired heart, hard to find such an excuse, really happy)
I want to pass a series of articles pandas
This allows you to learn a simple module
Then also the way to write fun stuff
Miya ~
Each article, let you read it silky smooth
Go ahead and pandas, series function
Part blog, we will go a little understanding of the function of a series of Diudiu
Enough
of this, let's continue
Heart meditation
pandas is processing data, the processing is the number of digits
OK, GET to this was much better
Later I made up just fine
import pandas as pd
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
print(s)
I created a basic Series, then it should be dealt with
For a linear data for
We can do many things
For example, I want to get the maximum and minimum
import pandas as pd
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
print(s.min())
print(s.max())
This wording is too simple, it does not show up we learn something
We get some fresh (actually the official website of the more complex examples)
Give a series to create an index with the level of
With the level of the index, What do you mean?
In fact, excel merged cells inside
look at the code
idx = pd.MultiIndex.from_arrays([
['warm', 'warm', 'cold', 'cold'],
['dog', 'falcon', 'fish', 'spider']]
,names=['blooded', 'animal'])
s = pd.Series([4, 2, 0, 8], name='legs', index=idx)
print(s)
A cold-blooded and warm-blooded animals on the table regarding how many feet
Well, a long piece of text output long like this
Do not understand, it does not matter, put excel inside Chou Chou
What kind of loud noise, a small version of a row, clarity
On a table
ahead of the current index is still
real data on the row behind
The operator then some
idx = pd.MultiIndex.from_arrays([
['warm', 'warm','warm', 'cold', 'cold'],
['dog', 'falcon','people', 'fish', 'spider']]
,names=['blooded', 'animal'])
s = pd.Series([4, 2,2, 0, 8], name='legs', index=idx)
print(s)
print(s.min())
print(s.max(level='blooded'))
The latter is to control the level of multiple indexes oh ~
See the results, you can understand it in seconds?
s = pd.Series([4, 2,2, 0, 8], name='legs', index=idx)
print(s)
print(s.min()) # 输出0
print(s.max(level='blooded')) # 输出 下面的表格
Yes, I am following table
Learn it, the learned, min, max, sum, idxmin, idxmax you will be a
What idx is what? Take a look at the above code
that is indexed ... ...
But also a long-winded property
For the series, the property also has a very, very important, after important to use, lacks effect?
This property is T
Yes, a capital letter T
Ha ha ha, in fact, this attribute for series, the basic futile
After using or equal to itself
s = pd.Series([3,1,4],index=['a','b','c'])
print(s)
print(s.T)
Continue to look at the function
Like wandering, and how to see the property
Continue to look at the function ah
A linear messy data, for us,
can also sort ah
import pandas as pd
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
Since the sort, as you guess, you can guess (in fact, most people simply could not guess, the teacher will think you can guess)
A is ordered by values, in accordance with a sorting index
import pandas as pd
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
print(s.sort_values())
print(s.sort_index())
Some sort of parameters, can often
Series.sort_values(axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last')
- axis which reference axis sorted for Series, it can only be set to 0
- ascending descending or ascending positive sequence True
- inplace default false, amended as true, in situ modification? Hey, I do not understand it, for a while I'll give you an chestnuts
- kind sorting method quick sort, merge sort, heap sort
- na_position null value, or at the front post, this, you try to know the
inplace
Look at the following code, replace situ
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
sorted_s = s.sort_values(inplace=True)
print(sorted_s)
This time print out is None, but you can print s, text can appear after ordering
I did not understand?
S is the variable directly to the sort of
After sorting it out, we should attempt to get part of series
Get a few head
Head head head
Acquired at the end of a few
tail,tail
import pandas as pd
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
print(s.head(2))
print(s.tail(2))
Data acquisition section can, then certainly you can delete the data myself
(I unhesitatingly say)
Series.drop
import pandas as pd
s = pd.Series([3,1,4,1,5,9,2,6,8,3,6])
print(s.drop(labels=[0,1]))
For the series is, labels parameter is mandatory
why? Since the other simply does not support
The new version can be replaced with index labels
Well, they learn new knowledge of it
Not too much, just a few
Daily learn a little of it, ah
Diansha write tomorrow, it may be DataFrame
Finally, welcome attention to the public a number of nagging programming engineers, undergraduate non-programmers
Took out your cell phone, take this