Categories
Mastering Development

how to take only last transaction to count timediff mysql 5.7

this is the continue question from find out time difference for every user in condition mysql 5.7 this is my fiddle https://dbfiddle.uk/?rdbms=mysql_5.7&fiddle=31b3be9d1e2444eb0b32c262176aa4b4 i have this table CREATE TABLE test ( ID INT, user_id INT, createdAt DATE, status_id INT ); INSERT INTO test VALUES (1, 13, ‘2020-01-01’, 8), (2, 13, ‘2020-01-03’, 8), (3, 13, ‘2020-01-06’, 8), […]

Categories
Mastering Development

Using function in javascript to get real time value

I want to get the value of a variable as many times as the user clicks a button. I am using the P5.js editor. let button; let upScore =0 ,preScore=0; let run = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; function setup() { createCanvas(200, 200); background(128); button = createButton(‘click me’); button.position(60, 100); […]

Categories
Mastering Development

Shiny update table content based on pickerinput selection

This is my first time using shiny. I built a database to feed an existing app. the new module I created (by modifying a by_country page one is too complex) and is not fully working. The table "tablepreped.xlsx" is displaying and so are the drop-down menus but the filtering of the table is not updating […]

Categories
Mastering Development

ggplot cumulative line plot with custom month order

I need to plot the cumulative sum for each month for different fiscal years. Fiscal year start in October and ends in September. total <- c(5, 2, 3, 4, 7, 4, 7, 8, 5, 6, 2, 25, 7 ,8, 0, 6, 4, 4) fiscal_year <- c(19, 19, 19, 19, 19, 19, 19, 19, 19, 19, […]

Categories
Mastering Development

Read a list from a csv row ‘as a list’ in python using DictReader

My CSV file looks like this: id,name,list 1,Beans,[1,2,3] 2,Spam,[5,6,7] 5,Spam,[7,8,9] When I try to read the last column using the following code: with open(‘some.csv’, newline=”) as csvfile: reader = csv.DictReader(csvfile) for row in reader: print(row["list"]) the output i get is: [1 [5 [7 Apparently, it separates the list at the first ‘,’. However i want […]

Categories
Mastering Development

Filter Array of Arrays in JavaScript to become unique [duplicate]

This is how I would filter an array of numbers to become unique: const unique = (value, index, self) => { return self.indexOf(value) === index } const costs = [10, 8, 5, 5, 8, 7] const uniqueCosts = costs.filter(unique) console.log(uniqueCosts) // [10,8,5,7] How could I filter an array of arrays to be unique: arr = […]

Categories
Mastering Development

How to Create Variables from OLS Regression Results?

import numpy as np import pandas as pd from scipy import stats import statsmodels.api as sm import matplotlib.pyplot as plt d = {‘City’: [‘Tokyo’,’Tokyo’,’Lisbon’,’Tokyo’,’Madrid’,’Lisbon’,’Madrid’,’London’,’Tokyo’,’London’,’Tokyo’], ‘Card’: [‘Visa’,’Visa’,’Visa’,’Master Card’,’Bitcoin’,’Master Card’,’Bitcoin’,’Visa’,’Master Card’,’Visa’,’Bitcoin’], ‘Client Number’:[1,2,3,4,5,6,7,8,9,10,11], } d = pd.DataFrame(data=d).set_index(‘Client Number’) df = pd.get_dummies(d,prefix=”, prefix_sep=”) X = df[[‘Lisbon’,’London’,’Madrid’,’New York’,’Tokyo’,’Bitcoin’,’Master Card’,’Visa’,’No’,’Yes’]] Y = df[‘Total’] X1 = sm.add_constant(X) reg = sm.OLS(Y, X1).fit() […]

Categories
Mastering Development

Slice can access another slice out of range but indexing out of range causes panic

My code: package main import ( "fmt" ) func main() { a := [10]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} b := a[1:4] fmt.Println("a:", a) fmt.Println("b:", b) // Works fine even though c is indexing past the end of b. c := b[4:7] fmt.Println("c:", c) // This fails with panic: runtime error: […]

Categories
User Help

Is it possible to reorder columns in a sorted range?

I’m creating a banking dashboard using google sheets ( which I prefer because it is supported by Tiller Money AND Notion, finally giving me near real time access to my data ). The core data sheet provided by Tiller is as one might expect, not perfect, offering too much and not enough information at the […]

Categories
Mastering Development

How to get last N records after JOIN in SQL?

I have three tables in mysql – Table 1: notes +—————+————-+——+—–+———+—————-+ | Field | Type | Null | Key | Default | Extra | +—————+————-+——+—–+———+—————-+ | id | int | NO | PRI | NULL | auto_increment | | user_id | int | NO | MUL | NULL | | | note_id | varchar(25) | […]