博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python Pandas -- DataFrame
阅读量:4708 次
发布时间:2019-06-10

本文共 1690 字,大约阅读时间需要 5 分钟。

pandas.DataFrame

class 
pandas.
DataFrame
(data=Noneindex=Nonecolumns=Nonedtype=Nonecopy=False)

Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure

Parameters:

data : numpy ndarray (structured or homogeneous), dict, or DataFrame

Dict can contain Series, arrays, constants, or list-like objects

index : Index or array-like

Index to use for resulting frame. Will default to np.arange(n) if no indexing information part of input data and no index provided

columns : Index or array-like

Column labels to use for resulting frame. Will default to np.arange(n) if no column labels are provided

dtype : dtype, default None

Data type to force. Only a single dtype is allowed. If None, infer

copy : boolean, default False

Copy data from inputs. Only affects DataFrame / 2d ndarray input

See also

constructor from tuples, also record arrays
from dicts of Series, arrays, or dicts
from sequence of (key, value) pairs

, , 

1. 先来个小菜

  基于dictionary创建

from pandas import Series, DataFrameimport pandas as pd  import numpy as npd = {
'col1':[1,2],'col2':[3,4]}df = pd.DataFrame(data=d)print(df)print(df.dtypes)# col1 col2#0 1 3#1 2 4#col1 int64#col2 int64#dtype: object

基于Numy的ndarrary

df2 = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)),columns=['a', 'b', 'c', 'd', 'e'])print (df2)#   a  b  c  d  e#0  0  2  4  7  0#1  6  7  3  4  1#2  5  3  3  8  7#3  0  9  4  3  4#4  7  4  7  0  0

 

转载于:https://www.cnblogs.com/Jesse-Li/p/8808225.html

你可能感兴趣的文章
【 henuacm2016级暑期训练-动态规划专题 A 】Cards
查看>>
第五篇:白话tornado源码之褪去模板的外衣
查看>>
设备常用框架framework
查看>>
bootstrap模态框和select2合用时input无法获取焦点(转)
查看>>
MockObject
查看>>
BZOJ4516: [Sdoi2016]生成魔咒(后缀自动机)
查看>>
查看手机已经记住的WIFI密码
查看>>
最新版IntelliJ IDEA2019 破解教程(2019.08.07-情人节更新)
查看>>
C# 两个datatable中的数据快速比较返回交集或差集
查看>>
关于oracle样例数据库emp、dept、salgrade的mysql脚本复杂查询分析
查看>>
adb shell am 的用法
查看>>
iOS10 UI教程视图和子视图的可见性
查看>>
FindChildControl与FindComponent
查看>>
中国城市json
查看>>
android下载手动下载Android SDK
查看>>
C++学习:任意合法状态下汉诺塔的移动(原创)
查看>>
leetcode133 - Clone Graph - medium
查看>>
UNET学习笔记2 - 高级API(HLAPI)
查看>>
"ORA-00942: 表或视图不存在 "的原因和解决方法[转]
查看>>
Oauth支持的5类 grant_type 及说明
查看>>