#!/usr/bin/env python #-*-coding:utf-8-*-# @Time: 4/14/18 11:17 AM # @Author: Aries # @Site: # @File:
main.py # @Software: Pycharm ' reference: https://www.cnblogs.com/misswangxing/p/7903595.html pandas Getting Started: 1 basic knowledge Pandas:
Meaning: The Python data Analysis Library is a numpy based tool.
Abbreviation: Panel data,data Analysis Features: 1 introduction of the standard data model, provide processing data Method 2 provides a good supporting data structure for time series analyses: Series: An array similar to a one-dimensional array in NumPy, similar to the list Difference: The elements in the list can be of different data types, and array and Series only allow the same data types to be stored time-series: time-indexed Series Dataframe: Two-dimensional tabular data structures, Series container Panel: three-dimensional arrays,
Dataframe container Pandas defined data type: Series and Dataframe installation: Pip Install pandas 2 pandas uses 3 Series Series same list, some column data, each data corresponds to an index value.
Series is a set up. The list essentially creates a Series object property that shows the series index and data value The default series index is actually an integer series can customize the index (at this point, it can be considered a dictionary) to have an indexed effect: Based on the index operation element Defines three forms of Series: 1 list forms, such as S = Series ([1, 4, ' www ', ' tt ']) 2 list + indexed form, such as S2 = Series ([' Chao ', ' Man ', ' ' "], index=[' name ', ' s Ex ', ' Age '] 3 dictionary form s4 = Series ({' score '): 329, ' age ': 29} ' custom index: The custom index will look for the original index, if the same is replaced with the original value of no value: for the Zishing to Nan judge whether is empty: pandas.is
Null (S4) S4.isnull ()Index assignment: s4.index=[' languages ', ' math ', ' Chinese '] look for elements in series after filtering conditions result = S4[S4 > 4 dataframe Meaning: Two-dimensional data structure, similar to spreadsheets and MySQL database Form vertical: Called Columns Rampage: Like series, called Index determines the position definition of a main clause by columns and index: A method that defines a Dataframe object, using the keys of the Dict dictionary: name, Marks, Price is the name of each dimension, which is the value of the name key of the columns: It's a list, there's no index, it's the default index columns the sequence can be defined as the order of the column names, which can be converted to the Dataframe index, as well as the custom example: data = {' name ': [' Google ', ' Baidu ', ' Yahoo '], ' marks ': [100,200,300], ' price ': [1,2,3]} f1 = Dataframe ( Data) F3 = Dataframe (data, columns=[' name ', ' Marks ', ' price '), index=[' A ', ' B ', ' C ']) dictionary nested dictionaries define another article that can be referenced: Https://blog. CSDN.NET/QQ_16234613/ARTICLE/DETAILS/62046057 Official Website: http://pandas.pydata.org/Time series-functionality:date Range Generation and frequency conversion, moving window statistics, moving window linear regressions, date shifting and Laggi
Ng.
Even create domain-specific time offsets and join time series without data;
' From pandas import Series from pandas import dataframe import pandas as PD
def process (): s = Series ([1, 4, ' www ', ' tt ']) print s print s.index print s.values s2 = Series ([' Ch
Ao ', ' Man ', ' index=['], "name", ' Sex ', ' age ']) print s2 print s2[' name ' s2[' name '] = ' chen ' Print s2
SD = {' score ': 329, ' age ':} s3 = Series (SD) print s3 S33 = Series ({' Score ': 329, ' age ':}) Print S33 S4 = Series (SD, index=[' Java ', ' score ', ' age ']) print S4 print Pd.isnull (S4) Print s4.isnull () s4.in
Dex = [' Language ', ' math ', ' Chinese '] print s4 S44 = S4 * 2 Print S44 result = S4[S4 > +] Print result Print type (result) def processdataframe (): data = {"Name": [' Google ', ' Baidu ', ' Yahoo '], "marks": [100, 200,300], "price": [1,2,3]} f1 = dataframe (data) print f1 F2 = dataframe (data, columns=[' name ', ' p Rice ', ' marks ']) print F2 F3 = Dataframe (data, columns=[' name ', ' Marks ', ' price '], index=[' A ', ' B ', ' C ']) PRI NT F3 print f3[' name'] NewData = {"Lang": {' a ': ' Python ', ' second ': ' Java '}, ' price ': {' A ': 5000, ' Second ':}} f4 = Dataframe (n Ewdata) Print F4 if __name__ = = "__main__": # Process () Processdataframe ()