Jeremy Barnes
Jeremy Barnes

Reputation: 662

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

Upvotes: 0

Views: 577

Answers (1)

MaxU - stand with Ukraine
MaxU - stand with Ukraine

Reputation: 210842

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

Upvotes: 1

Related Questions