pandas 获得“索引"给定索引的系列标签 [英] Pandas get the "index" label of a series given an index

查看:47
本文介绍了 pandas 获得“索引"给定索引的系列标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,由于缺乏词汇,这很令人困惑.

Ok, so this is confusing because of a lack of vocabulary.

Pandas 系列有一个索引和一个值:所以 'series[0]' 包含 (index,value).

Pandas series have an index and a value: so 'series[0]' contains (index,value).

如何通过索引系列从系列中获取索引(在我的情况下是日期)?这真的是一个非常简单的想法……它只是用索引"这个词加密了.哈哈.

How do I get the index (in my case it is a date), out of the series by indexing the series? This is really a very simple idea...it is just encrypted by the word "index." lol.

所以,换个说法,

当我的系列按日期索引时,我需要系列中第一个条目和最后一个条目的日期.

I need the date of the first entry in my series and the last entry, when my series is indexed by date.

为了清楚起见,我有一个按日期索引的系列,所以当我打印出来时,它会打印:

just to be clear, I have a series indexed by date, so when I print it out, it prints:

12-12-2008 1.2
12-13-2008 1.3
...

并打电话

df.ix[0] -> 1.2

我需要:

df.something[0] -> 12-12-2008

推荐答案

明白了.

 df.index[0]

在索引 0 处产生标签.

yields the label at index 0.

这篇关于 pandas 获得“索引"给定索引的系列标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆