data mining 2 (import numpy, pandas )

numpy: process the data& array

pandas:data analysis and explore

matplotlib:show with mat &plot 

scipy: matrix integration

statsmodels: statistic

Gensim:tex mining

sklearn、keras:computing learning’

 

numpy:

import numpy as nn
a=nn.array(["element1","element2","1","8a"])
a.sort()
b=nn.array([["key1","key2"],["1","2","0"],["a","2","0b"]])
b.sort()
print(a,b)
a1=a[0:4]
a2=a[:3]
a3=a[1:]
b1=b.max()
print(a[0],a1,a2,a3)
print(b[0][1],b1)

pandas:
import pandas as p
c=p.Series([2,2,3,4,5,3])
print(c)
c1=p.Series([3,4,5,6,7],index=["one","two","three","four","five"])
print(c1)
d=p.DataFrame([["a","b","c",2],[2,3,1,2,3,4,6]],columns=["one","two","three","four","five","six","seven"])
print(d)
d1=p.DataFrame({
"one":3,
"two":[3,4,5],
"three":list(str(233))
})
print(d1)
d2=d.head()#first five lines
d3=d.head(2)
d4=d.tail()#last five lines
d5=d.tail(3)
d6=d.describe()
d7=d.T# trans line to column
print(d2,d3,d4,d5,d6,d7)


['1' '8a' 'element1' 'element2'] [list(['1', '2', '0']) list(['a', '2', '0b']) list(['key1', 'key2'])]
1 ['1' '8a' 'element1' 'element2'] ['1' '8a' 'element1'] ['8a' 'element1' 'element2']
2 ['key1', 'key2']
0 2
1 2
2 3
3 4
4 5
5 3
dtype: int64
one 3
two 4
three 5
four 6
five 7
dtype: int64
one two three four five six seven
0 a b c 2 NaN NaN NaN
1 2 3 1 2 3.0 4.0 6.0
one three two
0 3 2 3
1 3 3 4
2 3 3 5
one two three four five six seven
0 a b c 2 NaN NaN NaN
1 2 3 1 2 3.0 4.0 6.0 one two three four five six seven
0 a b c 2 NaN NaN NaN
1 2 3 1 2 3.0 4.0 6.0 one two three four five six seven
0 a b c 2 NaN NaN NaN
1 2 3 1 2 3.0 4.0 6.0 one two three four five six seven
0 a b c 2 NaN NaN NaN
1 2 3 1 2 3.0 4.0 6.0 four five six seven
count 2.0 1.0 1.0 1.0
mean 2.0 3.0 4.0 6.0
std 0.0 NaN NaN NaN
min 2.0 3.0 4.0 6.0
25% 2.0 3.0 4.0 6.0
50% 2.0 3.0 4.0 6.0
75% 2.0 3.0 4.0 6.0
max 2.0 3.0 4.0 6.0 0 1
one a 2
two b 3
three c 1
four 2 2
five NaN 3
six NaN 4
seven NaN 6




posted @ 2017-10-24 16:09  兔子的尾巴_Mini  阅读(218)  评论(0编辑  收藏  举报