Categories
Mastering Development

avoid overwrite values using time series and forecast future value in loop R

I am running loop in R for time series (5y point) data. I want to get a result for new data (rata) using a formula (include initial and prior values). But, I get something weird. Gere is my code: n=7 set.seed(1) #data ta=c(1950,1955,1960,1965,1970,1975,1980) ra=c(1.7,1.3,-2.7,-2.4,3.3,5.7,1.7) rata=matrix(c(ta,ra),nrow=7) #rata ## initials a=runif(n,1,10) b=runif(n,0,10) c=runif(n,-100,100) d=runif(n,0,100) #priors p=runif(n,0,1) q=rnorm(n,c,d) […]

Categories
Mastering Development

Problem size and input pre-process costs in finding time complexity of an algorithm

I read different topics about time complexity on algorithms. I try to understand and learn how to analyze algorithms, but I still have some concerns. Therefore, I hope that this topic will help to make them clear. Here is a problem: Give an integer n (1 ≤ n ≤ 10^18). Removing digits at any positions […]

Categories
Mastering Development

Pandas: Time-weighted rolling average on ragged time series

I have a ragged (meaning not-a-regular frequency), time-indexed DataFrame, that I would like to perform a time-weighted rolling average on, that maintains the original index of the DataFrame. It is assumed that a recorded value is valid until superseded by another value. One way to achieve this is by just up-sampling the the ragged DataFrame […]

Categories
Mastering Development

Sorting dataframe by absolute value of a row

I have the following dataframe: import pandas as pd data = {0: [-1, -14], 1: [-3, 2], 2: [7, 10], 4: [-10, 15]} df = pd.DataFrame(data) I know how to sort an specific row: df.sort_values(by=0, ascending=False, axis=1) How is it possible to sort the dataframe by the absolute value of the first row? In this […]

Categories
User Help

Microsoft Excel – getting the right data

I have three 3 lists that a user selects from: Rating – AAA,AA,A,BBB Term, 1-3, 3-5, 5-7, 7-10, 10-15, 15+ Sector – Fin,Non-Fin, Sec/Col, Sovereign I’d then like to pick out the relevant cell from the screenshot after the user has selected a value from each list. I have the drop-downs in D4:D6 on another […]

Categories
User Help

Microsoft Excel – getting the right data

I have an intermediate usage level. There is 3 list cells with options, Rating, Term & Sector, I pick my 3 options then I have various tables with corresponding data on a different sheet, I hope to pick out the relevant data from these tables. (1 different table for each sector, columns term and rows […]

Categories
Mastering Development

MySQL query for multi-column distinct plus an ancillary column condition

Imagine a flat table that tracks game matches in which each game has three participants: an attacker, a defender and a bettor who is wagering on the outcome of the battle between players 1 and 2. The table includes the names of the players and the bettor of each game, as well as the date […]

Categories
Mastering Development

Make a new variable, var3, by taking the count of all values of var1 and dividing by unique values of var1, over unique values of var2

I’m trying to plot the average number of clicks on a given day over a one week period. The data i’m working with can be found here if you want to take a look. But briefly, it is structured as so: <class ‘pandas.core.frame.DataFrame’> RangeIndex: 400165 entries, 0 to 400164 Data columns (total 9 columns): uuid […]

Categories
Mastering Development

Python find higher high’s

I am trying to find the date and price of the next highest high in a pandas dataframe. example dataframe: Date Price 20200501 1.5 20200502 1.2 20200503 1.3 20200504 1.4 20200505 1.2 20200506 1.1 20200507 1.3 let’s say on 20200508 the high is 1.15. How can I retreive the following output from this dataframe? Date […]

Categories
Mastering Development

Sort array of objects by multiple properties, including objects in nested array

I know similar questions were asked here multiple times, but something doesn’t work there in my case. I have an array of objects with following structure: const items = [ {id: 100, title:’text’, path: ‘1’, readMessages: [ {text: ‘foo’, InsertDate: Moment} ], unreadMessages: [ {text: ‘bar’, InsertDate: Moment}, {text: ‘baz’, InsertDate: Moment} ]}, {id: 103, […]