Home > other >  Pandas how to select the current greater than 0, the next data is less than 0 index, thank you
Pandas how to select the current greater than 0, the next data is less than 0 index, thank you

Time:09-27

Such as data for:
A
0-1
1-2
2-3
3 1
4 2
5 3
6 4
7. 5
8-1
9-1
10-2
11 1
12 2
13 3
14 4
15 4
How pandas by index, it is concluded that the current index A value less than zero, and the next index greater than 0 index, such as the above index 2, accord with the requirement of me

CodePudding user response:

 
The import pandas as pd
Df=pd DataFrame ({' A ': [1, 2, or 3,1,2,3,4,5, 1, 1, 2,1,2,3,4,4]})
Dc1=df [' A '] <0
Dc2=df [r]. 'A' shift (periods=1, fill_value=https://bbs.csdn.net/topics/0)> 0
Print (df [dc1 & amp; dc2])


If no ready-made functions, my general ideas

CodePudding user response:

Title: pandas how to select the current greater than 0, the next data index less than zero?
Content: how pandas by index, it is concluded that the current index A value less than zero, and the next index greater than 0 index?

The title and content contradiction?
  • Related