Calculating moving averages for stock prices, visualizing

InterviewQs

Calculating moving averages for stock prices, visualizing

Python Pandas Moving Average Data Structures

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

Hi, 

Suppose you are given the following dataset containing closing prices of a stock across a number of days:

day price
0 1 119
1 2 146
2 3 147
3 4 119
4 5 102
5 6 124
6 7 148
7 8 140
8 9 133
9 10 153
10 11 155
11 12 162
12 13 150
13 14 171
14 15 167

Using this dataset, add a column with the 3 and 5-day moving averages for the closing prices. Then, visualize the output with a line chart.

To help get you started, here is code to load the same dataset into a Pandas dataframe:

    

#code to generate example dataframe

import pandas as pd

raw_data = {'day': [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],

'price': [119, 146, 147, 119, 102, 124, 148, 140, 133, 153, 155, 162, 150, 171, 167]

}

df = pd.DataFrame(raw_data, columns = ['day', 'price'])

Solution will be written in Python for premium users.




 

You’ve accumulated 288 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

Older messages

Writing a simple linear regression function

Monday, May 2, 2022

Python, Arrays, Linear Regression, User Input, InterviewQs Writing a simple linear regression function Python Arrays Linear Regression User Input Forward this email to a friend or colleague and

Bayesian analysis of Price is Right showcase

Friday, April 29, 2022

Python, Statistics, Bayes' Theorem, Modeling, Data Visualization, Baysian Inference, InterviewQs Bayesian analysis of Price is Right showcase Python Statistics Bayes' Theorem Modeling Data

Profit margins for all combinations of sales channels by org

Wednesday, April 27, 2022

SQL, Database Querying, Subquery, Cross Join, InterviewQs Profit margins for all combinations of sales channels by org SQL Database Querying Subquery Cross Join Forward this email to a friend or

Damage due to natural disasters

Monday, April 25, 2022

Python, Data Structures, External Dataset, Data Visualization, Data Processing, InterviewQs Damage due to natural disasters Python Data Structures External Dataset Data Visualization Data Processing

Maximizing value of your knapsack

Friday, April 22, 2022

Python, Arrays, Data Structures, Algorithms, InterviewQs Maximizing value of your knapsack Python Arrays Data Structures Algorithms Forward this email to a friend or colleague and challenge them to

You Might Also Like

Ranked | The Top 10 EV Battery Manufacturers 🔋

Tuesday, April 23, 2024

Asia dominates this ranking of the world's largest EV battery manufacturers in 2023. See which battery makers feature in the top 10. View Online | Subscribe Presented by: EnergyX's

Bringing PGO to the build pipeline

Tuesday, April 23, 2024

Plus how Go grew at Google, cmp.Or, and ways to visualize makefiles, Go binaries, and live Go processes. | #​504 — April 23, 2024 Unsub | Web Version Together with Three Dots Labs Go Weekly How Dolt

Noonification: Leetcode: Two-sum an Intuitive Approach

Tuesday, April 23, 2024

Top Tech Content sent at Noon! Get Algolia: AI Search that understands How are you, @newsletterest1? 🪐 What's happening in tech this week: The Noonification by HackerNoon has got you covered with

The best AI chatbot for coding

Tuesday, April 23, 2024

9 video gadget must-haves; 6 things Linux should borrow from MacOS -- ZDNET ZDNET Tech Today - US April 23, 2024 placeholder Can Meta AI code? I tested it against Llama, Gemini and ChatGPT - it wasn

Do I get to put your AI idea in front of 100K people?

Tuesday, April 23, 2024

If you build something great, I want to tell the world about it ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

UnitedHealth breach may affect huge portion of US citizens

Tuesday, April 23, 2024

The Change Healthcare ransomware attack has led to a massive leak of US healthcare data View this email online in your browser By Alex Wilhelm Tuesday, April 23, 2024 Good morning, and welcome to

LW 130 - Building a Product Configurator

Tuesday, April 23, 2024

Building a Product Configurator Shopify Development news and articles Issue 130 - 04/23/2024 Read Online Liquid Weekly All Things Shopify Development How to Sell Personalized Products on Shopify 2024 -

New public workshop in June: architecting for fast flow

Tuesday, April 23, 2024

Get the early bird discount You are receiving this email because you subscribed to the microservices.io mailing list. Helping organizations accelerate software delivery I provide consulting and

Pnpm v9.0.0; Biome v1.7; ESLint v9.1.0; Node.js collaboration summit; Intl.Segmenter; tree shaking;

Tuesday, April 23, 2024

We have 9 links for you - Stay up-to-date on JavaScript and tools WorkOS, the modern API for auth and user identity. workos.com Sponsor WorkOS enables B2B SaaS companies to accelerate enterprise

New on VC+: Our Visual Briefing on the IMF's World Economic Outlook Report 🔮

Tuesday, April 23, 2024

We've compiled a visual analysis of the most important takeaways from IMF's latest report. View email in browser EXCLUSIVE PREVIEW Upcoming on VC+: Our Key Takeaways from IMF's World