Data analysis using Python (vii)-Pandas Brief Introduction (series and Dataframe)

Source: Internet
Author: User


First, what is Pandas?
Pandas is a Python data analysis package based on NumPy, and the main purpose is toData Analysis。 It provides a large number of advancedData StructureAndfor data processingThe method. The pandas has two main data structures: SeriesAnd DataFrame
Second, Series
Series is aone-dimensional array objects, similar to the one-dimensional array of NumPy. It contains a set of indexes in addition to a set of data, so it can be understood as a set of indexed arrays.
Convert a Python array into a Series object:
Convert a Python dictionary into a Series object:
When the specified index is not displayed, the Series automatically starts at 0 and the step is 1 to create an index of the data. You can also display the specified index by using the index parameter:
For a single data in a Series object, the corresponding data or re-assignment is obtained from the index, as in an ordinary array, but you can also pass in an array of indexes to get data or to reassign values without data:
To get the index or array contents of a Series object separately, you can use theIndexAndValuesProperties, such as:
Operations on Series Objects (index invariant):
Third, DataFrame
DataFrame is aTable TypeData structure. It providesordered ColumnsAnddifferent types of column values。 For example, a dictionary consisting of a NumPy array is converted to a DataFrame object:
DataFrame By default the column names are sorted alphabetically, and you want to specify the order of the columns? To pass in a dictionary of a column name:
If the incoming column name is not found, it does not error, but instead produces a list of NA values:
DataFrame can not only obtain data in the form of a dictionary index, but can also be obtained by means of attributes, for example:
To modify the value of a column: Delete a column:
The next essay is: Data analysis using Python (eight) Pandas-summary statistics and calculation, interested friends Welcome to pay attention to this blog, but also welcome you to add comments to discuss.

Data analysis using Python (vii)-Pandas Brief Introduction (series and 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.