Series(random.randint(1000,4000,size=10),index=list(range(10)))
https://blog.csdn.net/kingov/article/details/79513322
Series(data,index=‘AirCondition,Computer,SmartTV,PhoneTest‘.split(‘,‘)) #索引肯定是从列表中取,split()切割成列表
dict转Series: sf = Series(data)
参考:https://blog.csdn.net/Late_whale/article/details/103620013
data = {
‘test01‘:10,
‘test02‘:101,
‘test03‘:1001
}
sf = Series(data,index=‘test01 test02 test04‘.split())
找缺失数据
import pandas as pd
pd.isnull(sf)
-------------------------
test01 False
test02 False
test04 True
dtype: bool
找有数值数据,过滤掉缺失值
pd.notnull(sf)
----------------------
test01 True
test02 True
test04 False
dtype: bool
找出为空的数据,并打印
sf[pd.isnull(sf)]
-----------------
test04 NaN
dtype: float64
找出不为空的数据,并打印
sf[pd.notnull(sf)]
-------------------
test01 10.0
test02 101.0
dtype: float64
可以进行间的的运算
sf.name=‘测试数据‘ #指定数据是干嘛的
sf.index.name=‘测试类别‘ #指定index
sf.reset_index() # 转换dataframe对象直接将name转换为列名
参考:https://blog.csdn.net/snow__wei/article/details/100666418
https://zhuanlan.zhihu.com/p/131553804
import pandas as pd
from numpy import random
#随机产生形状(shape)为(3,3),范围的(1000,2000)里的整数
data = random.randint(1000,2000,size(3,3))
df = pd.DataFrame(data=data,columns=[‘A‘,‘B‘,‘C‘],index=[0,1,2])
df
-------------------------
A B C
0 1663 1981 1587
1 1001 1367 1443
2 1322 1443 1929
Pandas技巧之Series转换至DataFrame:https://www.jianshu.com/p/7618ab9ddc11
中期_1.Python的Numpy,Pandas库使用_ch06--numpy初始
原文:https://www.cnblogs.com/shijingwen/p/14745648.html