Python Pandas -- DataFrame

來源:互聯網
上載者:User

標籤:.com   form   bool   dimens   property   lse   mon   cut   nta   

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, 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

 

Python Pandas -- DataFrame

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.