0
$\begingroup$

I have two parameters: demand, ticket_qty.

demand is an integer and can have a possible range of [100 - 200]

ticket_qty is also an integer and can have a possible range of [0 - 200]

I want to visualize how values for the above parameters affect the functions below:

price = demand - tickets_qty

revenue = price * ticket_qty

In Excel I created two matrixes (price and revenue) with demand as row indexes and ticket_qty as column indexes and simply applied the formula for each cell based on the rules above. However, seeing as this is a Kaggle microchallenge, I'd like to perform this using Python so as to then be able to plot and show optimal levels of price/revenue and do all my work inside the Jupyter notebook.

Questions:

  • How would I go about doing this in Python? pandas? numpy?
  • In statistics/data science, what is this "process" of mapping out possible values called? So as to facilitate further research
$\endgroup$
1
$\begingroup$

It's probably fastest to do this using numpy, in which you can define the possible ranges of your values using numpy.arange as follows:

import numpy as np

demand = np.arange(100, 201, 1) # integers from 100-200 inclusive
ticket_qty = np.arange(0, 201, 1) # integers from 0-200 inclusive

If you then want to calculate the possibilities using the different values you can use the .outer method of the different universal numpy functions (i.e. numpy.subtract to subtract values) to get easily get the results without looping over the arrays.

$\endgroup$
1
  • $\begingroup$ thanks, will use this method in the future. $\endgroup$ – Andrea M Jan 20 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.