Quick start of pandas under ipython tool

Introduction to Pandas

Pandas is a tool set
for analyzing structured data in Python. The foundation is numpy: high-performance matrix operations. The
graphics library matplotlib: provides data visualization.

ipython tools

Open using the command line
Insert picture description here

Pandas core data structure

Series creation

Series is a one-dimensional labeled array. Any data (integer, floating point, string, Python Object) can be placed in the array. The
basic format:
s=pd.Series(data,index=index)
where index is a list, Used as a label for data. data can be of different data types: Python dictionary, ndarray object, a scalar value.
The nature of Series objects:
ndarray-like objects, dict-like objects, label alignment operations.
Insert picture description here

DataFrame creation

DataFrame is a two-dimensional array with row and column labels, which can be Excel tables, SQL database tables, and Series object dictionaries. It is the most commonly used data structure in Pandas.
Basic format:
df=pd.DataFrame(data,index=index,columns=columns)
where index is the row label, columns is the column label, data can be: one-dimensional numpy array, dictionary composed of list and Series, two-dimensional numpy Array, a Series, DataFrame object.
1. Create a one-dimensional date to
Insert picture description herecreate a two-dimensional array
Insert picture description here
2. Create a dictionary
Insert picture description here
Insert picture description here

Pandas basic operations

View element
  1. View the data in the first few rows The method of
    Insert picture description here
    directly finding the interval of the data is inefficient and Insert picture description here
    efficientInsert picture description here
    Insert picture description here
  2. View the data of a certain column
    Insert picture description here
  3. View the row labels, column labels and attributes of the data
    Insert picture description here
Data conversion

Insert picture description here

Sort

Data is sorted by row, column, and specific label
Insert picture description here

Numerical judgment

Numerical judgment of elements in the data
Insert picture description here

Copy data and modify elements

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42567027/article/details/107223415