Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 select data based on indice
#1
I have dataframe like this
month value
0 1 12.214394
1 2 -30.114391
2 3 1.343937
3 4 -29.290909
4 5 22.703789
5 6 14.211441
6 7 5.654198
7 8 -28.977440
8 9 8.361656
9 10 12.296993
10 11 18.193127
11 12 -20.491604
12 1 45.214394
13 2 10.885609
14 3 -14.656063
15 4 3.709091
16 5 8.703789
17 6 24.211441
18 7 -46.345802
19 8 4.022560
20 9 8.361656
21 10 -2.703007
22 11 -28.806873
I want to select the values based on the months like this [10,11,12,1,2,3, 10,11,12,1,2,3] and I want to ignore the
the first 123 so the starts from 10,11,12 but the 123 goes into the next year instead of picking from the beginning.

Thanks
Quote
#2
Sounds easy, try the following: df[(df.index > 4) & (df.month.isin([10, 11, 12, 1, 2, 3]))].
Quote
#3
Thanks works like a charm
Quote
#4
Hi , this copies both the month the values together, is there a way to get only the only values? in the same order as the months?
Quote
#5
df[(df.index > 4) & (df.month.isin([10, 11, 12, 1, 2, 3]))].value.values
or

df[(df.index > 4) & (df.month.isin([10, 11, 12, 1, 2, 3]))].value.tolist()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Sample based on the distribution of a feature to create more balanced data set dervast 0 64 Sep-25-2019, 05:56 PM
Last Post: dervast
  Grouping data based on rolling conditions kapilan15 0 213 Jun-05-2019, 01:07 PM
Last Post: kapilan15
  Select rows based on a criteria klllmmm 8 2,873 May-11-2017, 06:58 PM
Last Post: klllmmm
  Match two data sets based on item values klllmmm 7 2,256 Mar-29-2017, 02:33 PM
Last Post: zivoni
  how to select particular rows data from a array raady07 3 1,552 Mar-06-2017, 02:21 AM
Last Post: raady07

Forum Jump:


Users browsing this thread: 1 Guest(s)