#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
pandas 学习

字典形式的numpy

"""
from __future__ import print_function

import numpy as np
import pandas as pd

dates = pd.date_range('20130101', periods=6)
df = pd.DataFrame(np.arange(24).reshape((6,4)),index=dates, columns=['A','B','C','D'])

"""
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-02   4   5   6   7
2013-01-03   8   9  10  11
2013-01-04  12  13  14  15
2013-01-05  16  17  18  19
2013-01-06  20  21  22  23
"""

# print(df['A'])
print(df.A)

print(df[0:3])

"""
            A  B   C   D
2013-01-01  0  1   2   3
2013-01-02  4  5   6   7
2013-01-03  8  9  10  11
"""
print(df['20130102':'20130104'])

"""
A   B   C   D
2013-01-02   4   5   6   7
2013-01-03   8   9  10  11
2013-01-04  12  13  14  15
"""


print(df.loc['20130102'])
"""
A    4
B    5
C    6
D    7
Name: 2013-01-02 00:00:00, dtype: int64
"""

print(df.loc[:,['A','B']])
"""
             A   B
2013-01-01   0   1
2013-01-02   4   5
2013-01-03   8   9
2013-01-04  12  13
2013-01-05  16  17
2013-01-06  20  21
"""

print(df.loc['20130102',['A','B']])
"""
A    4
B    5
Name: 2013-01-02 00:00:00, dtype: int64
"""


print(df.iloc[3,1])
# 13

print(df.iloc[3:5,1:3])
"""
             B   C
2013-01-04  13  14
2013-01-05  17  18
"""

print(df.iloc[[1,3,5],1:3])
"""
             B   C
2013-01-02   5   6
2013-01-04  13  14
2013-01-06  21  22

"""

# 根据混合的这两种 ix

print(df.ix[:3,['A','C']])
"""
            A   C
2013-01-01  0   2
2013-01-02  4   6
2013-01-03  8  10
"""

print(df[df.A>8])
"""
             A   B   C   D
2013-01-04  12  13  14  15
2013-01-05  16  17  18  19
2013-01-06  20  21  22  23
"""



#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
pandas 学习

字典形式的numpy

"""
from __future__ import print_function

import numpy as np
import pandas as pd

dates = pd.date_range('20130101', periods=6)
df = pd.DataFrame(np.arange(24).reshape((6,4)),index=dates, columns=['A','B','C','D'])

"""
             A   B   C   D
2013-01-01   0   1   2   3
2013-01-02   4   5   6   7
2013-01-03   8   9  10  11
2013-01-04  12  13  14  15
2013-01-05  16  17  18  19
2013-01-06  20  21  22  23
"""

# print(df['A'])
print(df.A)

print(df[0:3])

"""
            A  B   C   D
2013-01-01  0  1   2   3
2013-01-02  4  5   6   7
2013-01-03  8  9  10  11
"""
print(df['20130102':'20130104'])

"""
A   B   C   D
2013-01-02   4   5   6   7
2013-01-03   8   9  10  11
2013-01-04  12  13  14  15
"""


print(df.loc['20130102'])
"""
A    4
B    5
C    6
D    7
Name: 2013-01-02 00:00:00, dtype: int64
"""

print(df.loc[:,['A','B']])
"""
             A   B
2013-01-01   0   1
2013-01-02   4   5
2013-01-03   8   9
2013-01-04  12  13
2013-01-05  16  17
2013-01-06  20  21
"""

print(df.loc['20130102',['A','B']])
"""
A    4
B    5
Name: 2013-01-02 00:00:00, dtype: int64
"""


print(df.iloc[3,1])
# 13

print(df.iloc[3:5,1:3])
"""
             B   C
2013-01-04  13  14
2013-01-05  17  18
"""

print(df.iloc[[1,3,5],1:3])
"""
             B   C
2013-01-02   5   6
2013-01-04  13  14
2013-01-06  21  22

"""

# 根据混合的这两种 ix

print(df.ix[:3,['A','C']])
"""
            A   C
2013-01-01  0   2
2013-01-02  4   6
2013-01-03  8  10
"""

print(df[df.A>8])
"""
             A   B   C   D
2013-01-04  12  13  14  15
2013-01-05  16  17  18  19
2013-01-06  20  21  22  23
"""



#!/usr/bin/env python3 # -*- coding: utf-8 -*- pandas 学习  字典形式的numpy A   B   C   D 2013-01-01   0   1   2   3 2013-01-02   4   5   6   7 2013-01-03   8   9  10  11 2013-01-04  12  13  14  15 2013-01-05  16  17  18  19 2013-01-06  20  21  22  23 # print(df['A']) A  B   C   D 2013-01-01  0  1   2   3 2013-01-02  4  5   6   7 2013-01-03  8  9  10  11 A   B   C   D 2013-01-02   4   5   6   7 2013-01-03   8   9  10  11 2013-01-04  12  13  14  15 A    4 B    5 C    6 D    7 Name: 2013-01-02 00:00:00, dtype: int64 A   B 2013-01-01   0   1 2013-01-02   4   5 2013-01-03   8   9 2013-01-04  12  13 2013-01-05  16  17 2013-01-06  20  21 A    4 B    5 Name: 2013-01-02 00:00:00, dtype: int64 # 13 B   C 2013-01-04  13  14 2013-01-05  17  18 B   C 2013-01-02   5   6 2013-01-04  13  14 2013-01-06  21  22 # 根据混合的这两种 ix A   C 2013-01-01  0   2 2013-01-02  4   6 2013-01-03  8  10 A   B   C   D 2013-01-04  12  13  14  15 2013-01-05  16  17  18  19 2013-01-06  20  21  22  23