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)