pandas中size方法_Pandas基本属性和方法

Series基本功能:

axes 返回行轴标签列表。

dtype 返回对象的数据类型(dtype)。

empty 如果系列为空,则返回True。

ndim 返回底层数据的维数,默认定义:1。

size 返回基础数据中的元素数。

values 将系列作为ndarray返回。

head() 返回前n行。

tail() 返回最后n行。

DataFrame基本功能

T 转置行和列。

axes 返回一个列,行轴标签和列轴标签作为唯一的成员。

dtypes 返回此对象中的数据类型(dtypes)。

empty 如果NDFrame完全为空[无项目],则返回为True; 如果任何轴的长度为0。

ndim 轴/数组维度大小。

shape 返回表示DataFrame的维度的元组。

size NDFrame中的元素数。

values NDFrame的Numpy表示。

head()返回开头前n行。

tail()返回最后n行。

T(转置)

返回DataFrame的转置。行和列将交换。

实例:

import pandas as pd

import numpy as np

# Create a Dictionary of series

d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Minsu','Jack']),

'Age':pd.Series([25,26,25,23,30,29,23]),

'Rating':pd.Series([4.23,3.24,3.98,2.56,3.20,4.6,3.8])}

# Create a DataFrame

df = pd.DataFrame(d)

print ("The transpose of the data series is:")

print df.T

执行上面示例代码,得到以下结果 -

The transpose of the data series is:

0 1 2 3 4 5 6

Age 25 26 25 23 30 29 23

Name Tom James Ricky Vin Steve Minsu Jack

Rating 4.23 3.24 3.98 2.56 3.2 4.6 3.8

axes

返回行轴标签和列轴标签列表

实例1:

#Create a series with 100 random numbers

s = pd.Series(np.random.randn(4))

print ("The axes are:")

print s.axes

执行上面示例代码,得到以下输出结果 -

The axes are:

[RangeIndex(start=0, stop=

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值