How to maintain decimals when dividing with numpy arrays in Python

So, I was working on implementing my own version of the Statsitical Test of Homogeneity in Python where the user would submit a list of lists and the fuction would compute the corresponding chi value. One issue I found was that my function was removing decimals when performing division, resulting in a somewhat innaccurate chi… Read More How to maintain decimals when dividing with numpy arrays in Python

Trying to find the inverse of the matrix in C, but the program is not calculating correctly

There was a question that I needed to find the inverse of the matrix (actually it’s about cryptography, but never mind) and to be honest the code works. Nevertheless, if you insert certain numbers into the matrix, the program just fail in to calculate it. Let me show you the code: #include <stdio.h> #include <stdlib.h>… Read More Trying to find the inverse of the matrix in C, but the program is not calculating correctly

Trying to input a fraction and split it into a list but it causes problem when the numbers are more than 1 digit

fraction = list(input("Enter: ")) print(fraction) When Inputting "99/100" I wanted it to print ["99", "/", "100"] not [‘9’, ‘9’, ‘/’, ‘1’, ‘0’, ‘0’] >Solution : You can use ".split" for this, for example: thing1 = "abcdef" thing1.split("c") Gives the output: [‘ab’, ‘def’] If you’re bored and fancy fighting some spaghetti code for your own interest,… Read More Trying to input a fraction and split it into a list but it causes problem when the numbers are more than 1 digit

How to get Year Mont and Quarter from time series in python

I have this dataset: date_time srch_id 2013-04-04 08:32:15 1 2013-04-04 08:32:15 1 .. 2013-06-30 19:55:18 332785 2013-06-30 19:55:18 332785 And I want to separate date_time into: YM (Year_Month),YMQ(Year_Month_Quarter),Y and M: date_time srch_id YMQ YM Y M 2013-04-04 08:32:15 1 2013-04-2 2013-04 2013 4 2013-04-04 08:32:15 1 2013-04-2 2013-04 2013 4 .. 2013-06-30 19:55:18 332785 2013-06-2… Read More How to get Year Mont and Quarter from time series in python

MySQL Throws error after defining the location of table

I have this ‘information’ table below with 4 columns in it: ‘creator_id’,’viewer_id’,’date_format’,’donation’ CREATE TABLE information ( creator_id INT NOT NULL, viewer_id INT NOT NULL, date_format DATE NOT NULL, donation INT NOT NULL ); INSERT INTO twitch.information(creator_id,viewer_id,date_format,donation) VALUES (10,11,’2014-01-02′,34), (20,14,’2014-01-02′,150), (30,15,’2014-01-02′,717), (31,17,’2014-01-02′,177), (32,17,’2014-01-06′,737), (33,16,’2014-01-07′,37), (40,18,’2016-03-08′,442), (41,19,’2016-03-09′,142), (42,10,’2016-03-10′,152), (43,11,’2016-03-11′,512), (44,12,’2016-01-12′,340), (60,0,’2012-01-02′,1000), (70,1,’2012-01-02′,100); SELECT creator_id, MAX(SUM(donation)/COUNT(donation)) AS "TOP… Read More MySQL Throws error after defining the location of table

How to calculate the session change of daily bars

I have a DF that looks like: date volume open close high low previous close 2022-05-02 1756159.0 118.38 119.57 120.34 116.49 2022-05-03 3217838.0 119.72 122.4 123.98 119.09 119.57 2022-05-04 2460350.0 121.69 126.3 126.69 121.44 122.4 2022-05-05 2123645.0 124.62 122.15 125.21 120.8 126.3 2022-05-06 1629034.0 120.88 121.08 121.88 118.0 122.15 2022-05-09 1861704.0 119.13 113.11 119.13 112.64… Read More How to calculate the session change of daily bars

SQL join manager from same table onto a row with their employees

To start, here’s a dummy table I’ve made to show the data I’m working with: employee title division email Boss Person boss o bp@email John Smith supervisor a jos@email Jane Smith supervisor b jas@email Leo Messi employee a lm@email Amanda Kessel employee a ak@email Derek Jeter employee b dj@email I want to end up with… Read More SQL join manager from same table onto a row with their employees