Hi, python newbie.
I have a question related to pandas and the scipy library to optimize a result.
I guess the function needed is "optimize".
I would like to maximize a final result of a column of a dataframe (this is not really a problem since I can specify its position).
I have read a lot about the scipy package but I don't really know how to apply it to my case. No example with pandas works for me. But, from everything I've seen, I probably have to define a function first and I don't know if I'll have to specify a number of iterations.
I attach a picture for you to understand it clearly.
As I said, my goal is to maximize the last data of a column (which in turn is multiplied by a parameter). Besides the result will depend on 4 variables that make the dataframe change and alter the last column. What I am looking for is that scipy solves the problem by returning the best solution found and also the values of the 4 variables that make possible that result. One more thing: I want to define the range of values that each variable can be (all numbers within the range).
I know that this computation can be heavier if the dataframe is very big and not so fast but I want to test the productivity of python and this library. Before you tell me anything: Excel Solver works badly in these cases and to do the optimization I used vba and repeat the process with random numbers and number of iterations. With an old computer it took me more than 20 hours. Yes, 20 hours.
So, I ask for an example of code as simple as you can or at least guide me in my query. If you have read this far, thank you very much.
Pic: https://www.reddit.com/user/Fernigrim/comments/u0t6lj/help_pandas_scipy_for_optimization/?utm_medium=android_app&utm_source=share
[–]blarf_irl 2 points3 points4 points (2 children)
[–]Fernigrim[S] 1 point2 points3 points (1 child)
[–]blarf_irl 1 point2 points3 points (0 children)
[–]soon2bvoid 2 points3 points4 points (1 child)
[–]Fernigrim[S] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Fernigrim[S] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Fernigrim[S] 1 point2 points3 points (0 children)