Python data analysis in practice

Author: Zen and the Art of Computer Programming

1 Introduction

Data analysis originated from the process of people's collection, arrangement and processing of data, and it is also the product of the concept of "data-driven". Data analysis usually includes multiple links, such as data acquisition, cleaning, calculation, visualization, etc., among which visualization is often the key to data analysis. The Python language has taken an important place in the field of data science. It has powerful libraries in the fields of statistics, machine learning, data visualization, etc., and can perform data analysis work efficiently and quickly. This article will focus on the commonly used toolkits in Python, mainly involving the use of numpy, pandas, matplotlib, seaborn, scipy, statsmodels, scikit-learn, tensorflow and other libraries.

2. Data Structure and Computation

2.1 Data structure

Python's data structures are very similar to other programming languages ​​such as Java. The following are some commonly used data structures:

  1. List (list): A list is an ordered sequence that can store different types of objects, and its elements can be accessed through indexes. The list supports adding, deleting, modifying and checking operations. Examples are as follows:

    lst = ['apple', 'banana', 'orange']
    print(lst[1]) # 输出'banana'
    
    lst.append('grape') # 添加元素到列表尾部
    lst.insert(2, 'pear') # 在索引2位置插入新元素
    del lst[2] # 删除索引值为2的元素
    
    if 'apple' in lst:
        lst.remove('apple') # 从列表中删除第一个'apple'元素
    
    for i in range(len(lst)):
        print(i, lst[i]) # 遍历列表并输出索引和元素值
    
    # 合并两个列表
    new_ls

Guess you like

Origin blog.csdn.net/universsky2015/article/details/132255970