Python中各个数据类型常见方法总结---实时性更新

总结:

一.Python中的主要数据类型:

  • Numbers(数字)
  • String(字符串)
  • List(列表)
  • Tuple(元组)
  • Dictionary(字典)


二.numpy中常见函数

1.numpy.linspace()函数:

numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)

在指定的间隔内返回均匀间隔的数字。

返回num均匀分布的样本,在[start, stop]。

这个区间的端点可以任意的被排除在外。

Parameters(参数):


start : scalar(标量)

The starting value of the sequence(序列的起始点).

stop : scalar

序列的结束点,除非endpoint被设置为False,在这种情况下, the sequence consists of all but the last of num + 1 evenly spaced samples(该序列包括所有除了最后的num+1上均匀分布的样本(感觉这样翻译有点坑)), 以致于stop被排除.当endpoint is False的时候注意步长的大小(下面有例子).

num : int, optional(可选)

生成的样本数,默认是50。必须是非负。

endpoint : bool, optional

如果是真,则一定包括stop,如果为False,一定不会有stop

retstep : bool, optional

If True, return (samplesstep), where step is the spacing between samples.(看例子)

dtype : dtype, optional

The type of the output array. If dtype is not given, infer the data type from the other input arguments(推断这个输入用例从其他的输入中).

New in version 1.9.0.

Returns:

samples : ndarray

There are num equally spaced samples in the closed interval [start, stop] or the half-open interval [start, stop) (depending on whether endpoint is True or False).

step : float(只有当retstep设置为真的时候才会存在)

Only returned if retstep is True

Size of spacing between samples.

三.pandas中常见函数

1.DataFrame

1.1 创建:通常以传入一个字典的方式来创建df:
  1. df = pd.DataFrame(data={'books':['bk1','bk1','bk1','bk2','bk2','bk3'], 'price': [12,12,12,15,15,17]})  


注意:取值的时候是两个中括号。


1.2groupby()函数中的as_index参数



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值