Pandas 基本的数据结构

Pandas 基本的数据结构

Excel中的数据准备为:
Pandas 基本的数据结构_第1张图片

import pandas as pd
import numpy as np
    
def main():
    s = pd.Series([i*2 for i in range(1, 11)])
    print(type(s))    # The result is 
    dates = pd.date_range("20170301", periods=8)
    df = pd.DataFrame(np.random.randn(8, 5), index=dates, columns=list("ABCDE"))
    print(df)

if __name__ == "__main__":
    main()

结果为:

              A         B         C         D         E
2017-03-01  0.223637  1.544255 -1.399834 -1.156175 -1.436645
2017-03-02  0.348758 -0.003057 -0.266523  0.572191  0.561758
2017-03-03  0.552746  2.170823  0.349881  0.434880 -0.528127
2017-03-04 -0.333170  0.460260 -0.061805 -0.210423  0.303948
2017-03-05 -1.070272 -0.658485 -0.802647  0.424232 -0.001124
2017-03-06  0.463180  0.412661 -0.368736 -0.905680  0.431316
2017-03-07 -3.123026 -0.965136  0.114871 -0.327244  1.349307
2017-03-08 -0.473533  0.974456  1.589528  0.332258  1.922553

你可能感兴趣的:(Python编程基础,Pandas,基本的数据结构)