pandas.DataFrame

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

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

DataFrame.from_records
constructor from tuples, also record arrays
DataFrame.from_dict
from dicts of Series, arrays, or dicts
DataFrame.from_items
from sequence of (key, value) pairs

pandas.read_csvpandas.read_tablepandas.read_clipboard

1. 先来个小菜

基于dictionary创建

from pandas import Series, DataFrame
import pandas as pd
import numpy as np
d = {'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

Python Pandas -- DataFrame的更多相关文章

  1. Python pandas DataFrame操作

    1. 从字典创建Dataframe >>> import pandas as pd >>> dict1 = {'col1':[1,2,5,7],'col2':['a ...

  2. Python pandas.DataFrame调整列顺序及修改index名

    1. 从字典创建DataFrame >>> import pandas >>> dict_a = {'],'mark_date':['2017-03-07','20 ...

  3. python pandas.DataFrame选取、修改数据最好用.loc,.iloc,.ix

    先手工生出一个数据框吧 import numpy as np import pandas as pd df = pd.DataFrame(np.arange(0,60,2).reshape(10,3) ...

  4. python pandas dataframe to_sql方法error及其解决

    今天遇到了一个问题,很是奇怪,自己也想了一个另类的方法将其解决了,现在将详细过程经过记录如下: 我在处理完一个dataframe之后,需要将其写回到数据库.这个dataframe比较大,共有53列,7 ...

  5. python pandas.DataFrame.append

    1.使用append首先要注意的是,你要合并两个DataFrame的columns即列名是否是相同的,不相同的就会报错. 2.我们会发现DataFrame的列名是不能够重复的,而行名(index)是可 ...

  6. python pandas dataframe 操作记录

    从数据看select出数据后如何转换为dataframe df = DataFrame(cur.fetchall()) 如何更改列名,选取列,进行groupby操作 df.columns = ['me ...

  7. python pandas.DataFrame .loc,.iloc,.ix 用法

    refer to: http://www.cnblogs.com/harvey888/p/6006200.html

  8. python pandas dataframe 读取和写入Oracle

    1.代码:主要写入时表要为小写,否则报错 Could not reflect: requested table(s) not available in Engine from sqlalchemy i ...

  9. python pandas.Series&&DataFrame&& set_index&reset_index

    参考CookBook :http://pandas.pydata.org/pandas-docs/stable/cookbook.html Pandas set_index&reset_ind ...

随机推荐

  1. Python Matplotlib.plot Update image Questions

    1. 最近在测试一款设备,采集了一些设备后需要一帧一帧显示图像,经常使用Python,所以选用了Matplotlib进行图像操作 数据结构: timesatamp polar_distance hor ...

  2. Boost log中的几个问题

    1. 使用动态库时,要定义 BOOST_LOG_DYN_LINK  或者 BOOST_ALL_DYN_LINK 否则会出现如下错误: CMakeFiles/xxxx.dir/xxxx.cpp.o: I ...

  3. Apache Thrift with Java Quickstart(thrift入门及Java实例)

    thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发.它结合了功能强大的软件堆栈和代码生成引擎,以构建在 C++, Java, Python, PHP, Ruby, Erlang, Perl ...

  4. bzoj4619 4619: [Wf2016]Swap Space

    传送门 分析 首先不难想到我们要先处理容量变大的再处理容量变小的 对于第一种情况我们自然要选择x小的先格式化,因为这个样暂时存储所需空间较小,可以使得情况更优 而第二种情况y先考虑,因为这样对总空间的 ...

  5. 几种jar转exe方法的比较

    原摘自:https://blog.csdn.net/uikoo9/article/details/7458666 几种jar转exe方法的比较 2012年04月13日 17:33:07 阅读数:153 ...

  6. java反射中,Class.forName和classloader的区别

    http://blog.csdn.net/qq_27093465/article/details/52262340

  7. python---pyspider,报错?

    conf.json文件内容如下: { "message_queue": "redis://127.0.0.1:6379/15", "webui&quo ...

  8. jQuery 事件 - trigger() 方法

    <html> <head> <script type="text/javascript" src="/jquery/jquery.js&qu ...

  9. 最新Android的SDK版本与API Level的对应关系

    Android   7.1.1                                   API Level  25   Android   7.0                     ...

  10. ubantu一些资料

    1.在引导页面中选中win10 按E键 进入编辑 在最后一行后面加上一行ntldr /bootmgr 再按F10引导,发现可以进入windows10 2.ubantu安装qq https://lear ...