Calculating utilization rates of storage units

InterviewQs

Calculating utilization rates of storage units

Python Data Structures External Dataset

Forward this email to a friend or colleague and challenge them to solve it.

Hi, 

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:

unit_num total_revenue pct_utilization
1 XXX YYY
2 ZZZ WWW
... ... ...

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')

Our solution will be written using Python for premium users.


 

You’ve accumulated 376 questions since joining our email list. Create a premium account to access detailed solutions to each problem (including this one) + our new Case studies.


Was this email forwarded to you? You can join our list here to receive questions

How did you like today's question?

15411 Boischatel, Montreal, QC, H9H1Y7, Canada
Don't want to get these emails anymore? We'll forgive you if you unsubscribe

Key phrases

Older messages

Array algorithm, noting complexity

Wednesday, November 23, 2022

Python, Data Structures, Arrays, Complexity, Big O, InterviewQs Array algorithm, noting complexity Python Data Structures Arrays Complexity Big O Forward this email to a friend or colleague and

Removing a trend from time series data

Monday, November 21, 2022

Detrending, Machine Learning, Data Manipulation, Python, Forecast, InterviewQs Removing a trend from time series data Detrending Machine Learning Data Manipulation Python Forecast Forward this email to

Calculating cumulative sales with windowing functions

Friday, November 18, 2022

SQL, Database Querying, Window Function, Cumulative Sum, Subquery, InterviewQs Calculating cumulative sales with windowing functions SQL Database Querying Window Function Cumulative Sum Subquery

Setting up a custom alert system for changes to a URL

Wednesday, November 16, 2022

Python, Data Structures, External Dataset, InterviewQs Setting up a custom alert system for changes to a URL Python Data Structures External Dataset Forward this email to a friend or colleague and

Calculating the Root Mean Squared Error (RMSE) of a model

Monday, November 14, 2022

Python, Data Structures, RMSE, Arrays, InterviewQs Calculating the Root Mean Squared Error (RMSE) of a model Python Data Structures RMSE Arrays Forward this email to a friend or colleague and challenge

You Might Also Like

JSter #218 - Libraries and more

Wednesday, May 1, 2024

All JavaScript is good JavaScript. I'm close to done with my SurviveJS rework. The new site will have more content while being much lighter and faster to compile so that's all good. Libraries

BetterDev #258 - Build an 8-bit computer from scratch and Home automation with ESP8266

Wednesday, May 1, 2024

Better Dev #258 Apr 30, 2024 Hi all, We come back with a new issue this week. If you like BetterDev, please help spead word out by refer to your friends. Buy me a coffee would be great too. Build an 8-

Interface Interference 👎

Wednesday, May 1, 2024

Amid the AI device dunking, should everything “just be an app”? Here's a version for your browser. Hunting for the end of the long tail • April 30, 2024 Interface Interference The problem

Some Tesla Supercharger jobs get a jolt

Tuesday, April 30, 2024

Plus: Amazon CodeWhisperer changes its name and Arc gets a Windows version View this email online in your browser By Christine Hall Tuesday, April 30, 2024 Welcome to TechCrunch PM, bringing you the

Relief From Tinnitus: Free Discovery Call!

Tuesday, April 30, 2024

Do you suffer from tinnitus or a ringing in your ears? 1 in 3 adults over the age of 65 will suffer from this condition and often don't know there are things you can do to help. Our friends at

WebAIM April 2024 Newsletter

Tuesday, April 30, 2024

WebAIM April 2024 Newsletter Read this newsletter online at https://webaim.org/newsletter/2024/april Feature Web Accessibility in the 2024 Presidential Campaigns WebAIM's John Northup ran the US

👀 Being More Productive on a Smaller Screen — How to Hide Games on Steam Family Sharing

Tuesday, April 30, 2024

Also: What to Expect From Apple's "Let Loose" Event, and More! How-To Geek Logo April 30, 2024 Did You Know The letter J is the only letter that makes no appearance on the Periodic Table.

PEP 686, Lazy Evaluation, Serverless Python, and More

Tuesday, April 30, 2024

PEP 686: Make UTF-8 Mode Default #627 – APRIL 30, 2024 VIEW IN BROWSER The PyCoder's Weekly Logo PEP 686: Make UTF-8 Mode Default This Python Enhancement Proposal outlines making UTF-8 the default

Daily Coding Problem: Problem #1427 [Easy]

Tuesday, April 30, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Amazon. Given an array and a number k that's smaller than the length of the array,

🎙 My advice for film + TV creatives on the AI wave

Tuesday, April 30, 2024

Learning AI fast + Karate Kid references ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌