For example we have dataframe like this:

                   SPY        AAPL         IBM        GOOG         GLD
2017-01-03 222.073914 114.311760 160.947433 786.140015 110.470001
2017-01-04 223.395081 114.183815 162.940125 786.900024 110.860001
2017-01-05 223.217606 114.764473 162.401047 794.020020 112.580002
2017-01-06 224.016220 116.043915 163.200043 806.150024 111.750000
2017-01-09 223.276779 117.106812 161.390244 806.650024 112.669998
...

Now we only we want to get highlighted part:

                   SPY        AAPL         IBM        GOOG         GLD
2017-01-03 222.073914 114.311760 160.947433 786.140015 110.470001
2017-01-04 223.395081 114.183815 162.940125 786.900024 110.860001
2017-01-05 223.217606 114.764473 162.401047 794.020020 112.580002
2017-01-06 224.016220 116.043915 163.200043 806.150024 111.750000
2017-01-09 223.276779 117.106812 161.390244 806.650024 112.669998

We can use Dataframe.ix[] method to get date related index data from the list.

if __name__ == '__main__':
data=get_data()
data=data.ix['2017-12-01':'2017-12-15', ['IBM', 'GOOG']]
print(data)
"""
IBM GOOG
2017-12-01 154.759995 1010.169983
2017-12-04 156.460007 998.679993
2017-12-05 155.350006 1005.150024
2017-12-06 154.100006 1018.380005
2017-12-07 153.570007 1030.930054
2017-12-08 154.809998 1037.050049
2017-12-11 155.410004 1041.099976
2017-12-12 156.740005 1040.479980
2017-12-13 153.910004 1040.609985
2017-12-15 152.500000 1064.189941
"""

[Python] Slice the data with pandas的更多相关文章

  1. [Python] Normalize the data with Pandas

    import os import pandas as pd import matplotlib.pyplot as plt def test_run(): start_date='2017-01-01 ...

  2. 一句Python,一句R︱pandas模块——高级版data.frame

    先学了R,最近刚刚上手python,所以想着将python和R结合起来互相对比来更好理解python.最好就是一句python,对应写一句R. pandas可谓如雷贯耳,数据处理神器. 以下符号: = ...

  3. Seven Python Tools All Data Scientists Should Know How to Use

    Seven Python Tools All Data Scientists Should Know How to Use If you’re an aspiring data scientist, ...

  4. arcgis python arcpy add data script添加数据脚本

    arcgis python arcpy add data script添加数据脚本mxd = arcpy.mapping.MapDocument("CURRENT")... df ...

  5. Python slice() 函数

    Python slice() 函数  Python 内置函数 描述 slice() 函数实现切片对象,主要用在切片操作函数里的参数传递. 语法 slice 语法: class slice(stop) ...

  6. [Machine Learning with Python] My First Data Preprocessing Pipeline with Titanic Dataset

    The Dataset was acquired from https://www.kaggle.com/c/titanic For data preprocessing, I firstly def ...

  7. Python数据科学安装Numby,pandas,scipy,matpotlib等(IPython安装pandas)

    Python数据科学安装Numby,pandas,scipy,matpotlib等(IPython安装pandas) 如果还没有本地安装Python.IPython.notebook等请移步 上篇Py ...

  8. 用pandas进行数据清洗(二)(Data Analysis Pandas Data Munging/Wrangling)

    在<用pandas进行数据清洗(一)(Data Analysis Pandas Data Munging/Wrangling)>中,我们介绍了数据清洗经常用到的一些pandas命令. 接下 ...

  9. Python For Data Analysis -- Pandas

    首先pandas的作者就是这本书的作者 对于Numpy,我们处理的对象是矩阵 pandas是基于numpy进行封装的,pandas的处理对象是二维表(tabular, spreadsheet-like ...

随机推荐

  1. SpringCloud学习笔记(18)----Spring Cloud Netflix之服务网关Zuul原理

    1. Zuul的工作机制 Zuul提供了一个框架,可以对过滤器进行动态的加载,编译,运行.过滤器之间没有直接的相互通信,他们是通过一个RequestContext的静态类来进行数据传递的.Requet ...

  2. Dapper基础知识二

    在下刚毕业工作,之前实习有用到Dapper?这几天新项目想用上Dapper,在下比较菜鸟,这块只是个人对Dapper的一种总结. 2,如何使用Dapper?     首先Dapper是支持多种数据库的 ...

  3. javascript 异或运算符实现简单的密码加密功能

    写在前面的 当我们需要在数据库中存储用户的密码时,当然是不能明文存储的. 我们就是介绍一下用^运算符来实现简单的密码加密以及解密功能 上代码 首先,回顾一下基础知识. String.fromCharc ...

  4. WebKit.NET-0.5简单应用(2)——音量解决方案

    查找WebKit.NET相关文档,没有找到音量控制解决方法.换思路进行解决,尝试用Win32 API进行解决 [DllImport("winmm.dll")] public sta ...

  5. [洛谷P1920]成功密码

    题目大意:给你n和x($n\leq 10^{18},0<x\leq 1$),要你求$\sum_{i=1}^n\frac{x^i}{i}$. 解题思路:首先n大到要用long long存,暴力肯定 ...

  6. js去掉字符串得第一个字符 、去掉字符串的最后一个字符

    a1 = aa[0].slice(1);  //去掉第一个字符串 a2 = a2.substr(0, a2.length - 1);

  7. BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第1章节--SharePoint 2013 介绍 处理开发者需求

    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第1章节--SharePoint 2013 介绍 处理开发者需求         SharePoint本质上是一个平台.你 ...

  8. 轻松学习JavaScript二十二:DOM编程学习之节点操作

    DOM编程不只能够查找三种节点,也能够操作节点.那就是创建,插入,删除.替换和复制节点.先来看节点 操作方法: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQ ...

  9. IIS预编译提升载入速度

    当我们把站点部署在IIS7或IIS6S的时候,每当IIS或是ApplicationPool重新启动后,第一次请求站点反应总是非常慢.原因大家都知道(不知道能够參考这个动画说明ASP.NET网页第一个R ...

  10. PhpStorm Live Template加PHP短语法Short Open Tags打造原生模板

    关于Php要不要使用模板一直被大家讨论,支持的说使用模板更简洁,易与前端project师交流.反对的说Php本身就支持内嵌语法,不是必需再用个模板,减少性能. 事实上使用Php的短语法.直接嵌入也不是 ...