Pythonz之pandas

pandas模块类似于字典形式的numpy

#pandas
import pandas as pd
import numpy as np
s = pd.Series([1,3,6,np.nan,44,1])
print(s)
dates = pd.date_range('20180711',periods=6)
print(dates)
df = pd.DataFrame(np.arange(12).reshape((3,4)))
print(df)
print(df.dtypes)
print(df.index)
print(df.columns)
print(df.values)
print(df.describe())
print(df.T)
print(df.sort_index(axis=1,ascending=False))#对列倒序
# print(df.sort_values(by='2'))对值排序

结果

0     1.0
1     3.0
2     6.0
3     NaN
4    44.0
5     1.0
dtype: float64
DatetimeIndex(['2018-07-11', '2018-07-12', '2018-07-13', '2018-07-14',
               '2018-07-15', '2018-07-16'],
              dtype='datetime64[ns]', freq='D')
   0  1   2   3
0  0  1   2   3
1  4  5   6   7
2  8  9  10  11
0    int32
1    int32
2    int32
3    int32
dtype: object
RangeIndex(start=0, stop=3, step=1)
RangeIndex(start=0, stop=4, step=1)
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
         0    1     2     3
count  3.0  3.0   3.0   3.0
mean   4.0  5.0   6.0   7.0
std    4.0  4.0   4.0   4.0
min    0.0  1.0   2.0   3.0
25%    2.0  3.0   4.0   5.0
50%    4.0  5.0   6.0   7.0
75%    6.0  7.0   8.0   9.0
max    8.0  9.0  10.0  11.0
   0  1   2
0  0  4   8
1  1  5   9
2  2  6  10
3  3  7  11
    3   2  1  0
0   3   2  1  0
1   7   6  5  4
2  11  10  9  8
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值