Plot stock Sum, validate, and plot monthly inventory levels over time with vectorized code
Group by references and date in a Plot stock levels over time with vectorized waycode
Reworked followingThe idea is that I have a subset of the advices in comments:movements of material of a factory (over 700k rows), and I want to separate these movements by the reference of each product to plot the stock of each product over time.
The idea is that I have a subset of the movements of material of a factory(over 700k rows), and I want to separate this movements by the reference of each product to plot the stock over time, butBut the dataframe have repeatshas repeated days, and the stock at the end of every month(STOCK FINALSTOCK FINAL
) is in another dataframe(inventario_dfinventario_df
), and. I get this final_stockthe final_stock
from the other dataframe because I wanted to see if the data from the 2two dataframes wereare the same (in the 1st output it is not the same, in the 2nd it is, so now I know that the company has some kind of problem with the reference of the 1st output).
And the intended output is the groups separate by the reference, summing the quantities of stock by day, and the last day of each month with a final stock. This value is taken from anotherthe other dataframe(inventory_dfinventory_df
), so one of the output groups would be:
In the code I have now, I have separated the groups in a dictionary so that I can access them later. Although mainly I mainly used the dictionary because I didn't know how to do all this in the same dataframe.
On the second group, the first 2 rows are the last days of each month because they didn't have any other move between on mvtos_material_dfmvtos_material_df
.
Reworked following the advices in comments:
The idea is that I have a subset of the movements of material of a factory(over 700k rows), and I want to separate this movements by the reference of each product to plot the stock over time, but the dataframe have repeats days, and the stock at the end of every month(STOCK FINAL) is in another dataframe(inventario_df), and I get this final_stock from the other dataframe because I wanted to see if the data from the 2 dataframes were the same (in the 1st output is not the same, in the 2nd it is, so now I know that the company has some kind of problem with the reference of the 1st output).
And the intended output is the groups separate by the reference, summing the quantities of stock by day, and the last day of each month with a final stock. This value is taken from another dataframe(inventory_df), so one of the output groups would be:
In the code I have now, I have separated the groups in a dictionary so that I can access them later. Although mainly I used the dictionary because I didn't know how to do all this in the same dataframe.
On the second group, the first 2 rows are the last days of each month because they didn't have any other move between on mvtos_material_df.
The idea is that I have a subset of the movements of material of a factory (over 700k rows), and I want to separate these movements by the reference of each product to plot the stock of each product over time.
But the dataframe has repeated days, and the stock at the end of every month(STOCK FINAL
) is in another dataframe(inventario_df
). I get the final_stock
from the other dataframe because I wanted to see if the data from the two dataframes are the same (in the 1st output it is not the same, in the 2nd it is, so now I know that the company has some kind of problem with the reference of the 1st output).
And the intended output is the groups separate by the reference, summing the quantities of stock by day, and the last day of each month with a final stock. This value is taken from the other dataframe(inventory_df
), so one of the output groups would be:
In the code I have now, I have separated the groups in a dictionary so that I can access them later. Although I mainly used the dictionary because I didn't know how to do all this in the same dataframe.
On the second group, the first 2 rows are the last days of each month because they didn't have any other move between on mvtos_material_df
.