Python Pandas学习笔记

Pandas适合处理类似Excel表格形式的数据,也就是在Numpy的基础上为每一行/列增加了名字。类似dict与list的关系
#!/bin/python3
#-*- coding: utf-8 -*-
import pandas as pd
import numpy as np

s = pd.Series([1, 2, 3], index=pd.date_range('20170101',periods=3))
print(s, "\n")

s = pd.Series([1, 2, 3], index=["k1", "k2", "k3"])
print(s, "\n")

s = pd.DataFrame(np.random.randn(3, 3), index=["R1", "R2", "R3"],
                      columns=['C1', 'C2', 'C3'])
print(s, "\n")

s = pd.DataFrame({'A' : [1, 2, 3],
                  'B' : [4, 5, 6]})
print(s, "\n")

s = pd.Panel(np.random.randn(2, 3, 3), items=['Item1', 'Item2'],
                    major_axis=["R1", "R2", "R3"],
                     minor_axis=['C1', 'C2', 'C3'])
print(s.values[0], "\n")


发表于:2017-10-25 10:12:11

原文链接(转载请保留): http://www.multisilicon.com/blog/a23271828.html

友情链接: MICROIC
首页