Connect a variable with the number of columns in a matrix
OngoingHello,
I have for example 4 products with the following information from a pandas dataframe df.:
product_1 product_2 product_3 product_4
mean 25,2 29,8 15,7 38,2
std. 4,8 6,1 2,9 9,1
In addition, I know in which order the products will be produced. This is defined like:
num_2 = [[0, 0], [1, 0]]
num_3 = [[0, 0, 0], [1, 0, 0], [0, 1, 0]]
num_4 = [[0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]]
sequence = num_4
matrix = pd.DataFrame(sequence, columns=products, index=products)
print(matrix, '\n')
Is there a possibility, to transfer the number of products into the variable sequence?
For example:
I have 4 products, which lead to 4 columns and therefore the variable should take the value
sequence = num_4
I know, that the number of columns is given by:
len(df.columns)
But can I integrate / add this information to "num_" ?
Best regards
Marc
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Marc,
I don't really understand what you are trying to do. This is also not a Gurobi-specific question and platforms like stackoverflow.com are way better suited for such questions.
I recommend you complete some Pandas tutorials first - Pandas is a powerful tool but not exactly beginner-friendly.
Cheers,
Matthias0
Post is closed for comments.
Comments
2 comments