Calculating utilization rates of storage units
Suppose you're analyzing the utilization of a small storage facility. Customers can rent out a unit on a monthly or annual basis. Monthly customers can end their rental at the end of each month, and annual customers can end their rental at the end of each year.
You have the following dataset, which shows each unit's monthly revenue and the type of rental contract. If a unit is not currently rented revenue will be 0 and there will be no customer_id.
Using all of this information, calculate the total revenue per unit and the utilization of each unit. Utilization can be calculated by taking the months the unit is in use and dividing by all months recorded. The resulting output should look like the example table below:
To help get you started, below is code (Python) to import the referenced datasets:
# Import libraries import pandas as pd import numpy as np # Import data df = pd.read_csv('https://raw.githubusercontent.com/erood/interviewqs.com_code_snippets/master/Datasets/storage_unit_revenue.csv')
Subscribe to premium account to see the solution.Get premium now