热线电话:13121318867

登录
2018-12-05 阅读量: 758
dataframe的帮助文档

DataFrame(data=None, index=None, columns=None, dtype=None, copy=False)

文档字符串:

二维大小可变、可能异构的表格数据

具有标记轴(行和列)的结构。算术运算

对齐行和列标签。可以被认为是像dict一样的

系列对象的容器。主要pandas数据结构。

参数

- - - - - - - - - - -

数据:numpy ndarray(结构化或同构)、dict或DataFrame

Dict可以包含序列、数组、常量或类列表的对象

. .versionchanged: 0.23.0

索引:索引或类数组

索引用于结果帧。如果是,是否默认为RangeIndex

输入数据中没有索引信息部分,也没有提供索引

列:索引或类数组

用于生成框架的列标签。将默认为

RangeIndex(0,1,2,…), n)如果不提供列标签

dtype: dtype,默认无

要强制的数据类型。只允许一个dtype。如果没有,推断出

复制:布尔值,默认为False

从输入复制数据。只影响DataFrame / 2d ndarray输入

例子

- - - - - - - - - -

从字典构造DataFrame。

>>> d = {'col1': [1,2], 'col2': [3,4]}

>>> df = pd.DataFrame(data=d)

> > > df

col1 col2

0 1 3

1 2 4

注意,推断出的dtype是int64。

> > > df.dtypes

col1 int64

col2 int64

dtype:对象

要执行单个dtype:

>>> df = pd。DataFrame (data = d, dtype = np.int8)

> > > df.dtypes

col1 int8

col2 int8

dtype:对象

从numpy ndarray构造数据框:

>>> df2 = pd.DataFrame(np.random)。randint(low=0, high=10, size=(5,5)),

…列=['a', 'b', 'c', 'd', 'e'])

> > > df2

a b c d e

0 2 8 8 3 4

1 4 2 9 0 9

2 1 0 7 8 0

3 5 1 7 1 3

4 6 0 2 2

另请参阅

- - - - - - - - - -

from_records:元组的构造函数,也可以记录数组

from_dict:来自串、数组或dicts的dicts

from_items:从(键,值)对的序列

pandas。read_csv,read_table, pandas.read_clipboard

0.0000
1
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子