简体   繁体   中英

How to extract part of pandas row as a series

I have a dataframe, df, with columns like

['Part Number', 'Category', '1.2013', '2.2013', ... , '12.2016']

And other text descriptor columns.

I have the dates a list and want to extract them from an arbitrary row as a series, indexed by the dates with the old value as the series values, with no other information included.

How can I accomplish this?

EG:

My first row would be something like

    Category  Part Number 1.2013 2.2013 3.2013
0   Engine      RJ45          0      0      0

and I want

1.2013    0
2.2013    0
3.2013    0
Name: RJ45, dtype: int64

Is that what you want?

In [121]: df.filter(regex='^\d+\.\d{4}').T
Out[121]:
        0
1.2013  0
2.2013  0
3.2013  0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM