'Grabbing a fixed portion of a dataframe colum each time in a loop, and plotting it
I have a very large dataframe of two columns. It has 1,848,000 rows on top of each other for each column. I want to assign & save each 15,400 rows of column #1 as unique layer (so basically layer #1 consists of 15,265 rows, Layer #2 consists of the next 15,625 rows, Layer #3 consists of the next 15,265 rows, etc until the last layer Layer #120). Then, I would like to plot their each layer absolute cum-sum of values (y) versus the layer number (x axis). So far, I have the below code, but I am not sure how to assign them inside a loop. Every 20 layer defines a whole model. I also want to see the model number inside the plot. First 20 layer is Model #1, the next 20 layer is Model #2, and so on.
For example:
Money = np.array(0, 1,848,000)
Sales = np.array(0, 1,848,000)
df = pd.DataFrame(list(zip(Money, Sales), columns = ['Money', 'Sales'])
periodic_index_limit = 15,400
count = np.arange(1, 20)
Model_number = np.array(0, 6)
for i in count:
df['Money'][i*periodic_index_limit]
...?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
