Rows of specific rows pandas dataframe

I have a pandas framework with three columns, and I draw each column separately using the following code:

data.plot(y='value') 

Which generates a figure like this:

enter image description here

I need a subset of these values, not all of them. For example, I want to build values ​​in rows from 500 to 1000, and not from 0 to 3500. Any idea how I can say that the graph function only selects them?

thanks

+7
python pandas plot
source share
1 answer

use iloc to cut off your df:

 data.iloc[499:999].plot(y='value') 

it will cut from line 500 to but not including line 1000

Example:

 In [35]: df = pd.DataFrame(np.random.randn(10,2), columns=list('ab')) df.iloc[2:6] Out[35]: ab 2 0.672884 0.202798 3 0.514998 1.744821 4 -1.982109 -0.770861 5 1.364567 0.341882 df.iloc[2:6].plot(y='b') 

enter image description here

+10
source share

All Articles