Python Pandas--DataFrame

Source: Internet
Author: User

Pandas. DataFrame
pandas. class DataFrame ( data=none, index=none, columns=none, dtype=none, copy=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 is 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. Would 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. Would default to Np.arange (n) If no column labels is 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_table,pandas.read_clipboard

1. Start with a side dish.

Create based on dictionary

 fromPandasImportSeries, DataFrameImportPandas as PDImportNumPy as NPD= {'col1': [+],'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

Ndarrary based on the Numy

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.