Categories
Mastering Development

ifelse() used with all() on multiple columns

I have this data: library(tidyverse) data <- tribble( ~a, ~b , ~c , ~d, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 ) and would like to get this output – if there is a zero in all columns TRUE is returned: # A tibble: 4 x […]

Categories
Mastering Development

How to convert json to csv after using an API export python

I used an API data export and ended up with this python dictionary/json format and get this: json_data = json.loads(response.text) [{‘key’: [‘a’, ‘b’, ‘c’], ‘value’: 1}, {‘key’: [‘d’, ‘e’, ‘f’], ‘value’: 2}, {‘key’: [‘g’, ‘h, ‘i’], ‘value’: 3}, ….. I have tried using pandas and df = pd.read_json and then df.to_csv but get a dataframe […]

Categories
Mastering Development

Measure structure of xy points – python

I’m trying to measure the overall formation of xy points taken over time. To achieve this, I want to calculate the vector between each point and the rest of the points at every timestamp. The average of these vectors between each pair of points should then provide the overall structure. Once the averages have been […]

Categories
Database Development

Even with 90000 NOFILE mongo crashes with Too many open files in system

we suddenly got MongoDB servers crashing on docker container mongo:4.4 with this error: couldn’t open [/proc/1/stat] Too many open files in system","file":"src/mongo/util/processinfo_linux.cpp","line":78} you can see the full log here: [36mdb_1 |[0m {"t":{"$date":"2020-12-01T12:47:43.080+00:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"conn60","msg":"Slow query","attr":{"type":"command","ns":"myDB.user","command":{"aggregate":"user","pipeline":[{"$match":{"__t":"user"}},{"$unwind":{"path":"$security.tokens.learner","preserveNullAndEmptyArrays":true}},{"$unwind":{"path":"$security.tokens.cp","preserveNullAndEmptyArrays":true}},{"$unwind":{"path":"$security.tokens.admin","preserveNullAndEmptyArrays":true}},{"$match":{"$or":[{"$or":[{"$and":[{"trash.status":false},{"$or":[{"learner.lock.status":false},{"learner.lock.status":{"$exists":false}}]},{"learner.suspend.status":false},{"security.tokens.learner.token":"asdjasdjkasdasdbashd"},{"security.tokens.learner.expireDate":{"$gte":{"$date":"2020-12-01T12:47:42.977Z"}}},{"shared.roles.learner":true}]},{"$and":[{"security.tokens.learner.token":"asdjasdjkasdasdbashd"},{"security.tokens.learner.expireDate":{"$gte":{"$date":"2020-12-01T12:47:42.977Z"}}},{"$or":[{"learner.lock.status":false},{"learner.lock.status":{"$exists":false}}]},{"learner.suspend.status":false},{"$or":[{"facebook.registered":true},{"google.registered":true},{"linkedin.registered":true}]}]}]},{"$and":[{"trash.status":false},{"$or":[{"cp.lock.status":false},{"cp.lock.status":{"$exists":false}}]},{"cp.suspend.status":false},{"security.tokens.cp.token":"asdjasdjkasdasdbashd"},{"security.tokens.cp.expireDate":{"$gte":{"$date":"2020-12-01T12:47:42.977Z"}}},{"shared.roles.cp":true}]},{"$and":[{"trash.status":false},{"$or":[{"admin.lock.status":false},{"admin.lock.status":{"$exists":false}}]},{"admin.suspend.status":false},{"security.tokens.admin.token":"asdjasdjkasdasdbashd"},{"security.tokens.admin.expireDate":{"$gte":{"$date":"2020-12-01T12:47:42.977Z"}}},{"shared.roles.admin":true}]}]}}],"cursor":{},"$db":"myDB"},"planSummary":"COLLSCAN","keysExamined":0,"docsExamined":1569,"cursorExhausted":true,"numYields":2,"nreturned":1,"queryHash":"167A82D6","planCacheKey":"C324EA6F","reslen":4753,"locks":{"ReplicationStateTransition":{"acquireCount":{"w":5}},"Global":{"acquireCount":{"r":5}},"Database":{"acquireCount":{"r":5}},"Collection":{"acquireCount":{"r":5}},"Mutex":{"acquireCount":{"r":3}}},"storage":{},"protocol":"op_msg","durationMillis":101}} [36mdb_1 |[0m {"t":{"$date":"2020-12-01T12:58:25.000+00:00"},"s":"E", "c":"-", "id":23077, "ctx":"ftdc","msg":"Assertion","attr":{"error":"Location13538: couldn’t open [/proc/1/stat] Too many open files in system","file":"src/mongo/util/processinfo_linux.cpp","line":78}} [36mdb_1 |[0m {"t":{"$date":"2020-12-01T12:58:25.339+00:00"},"s":"E", "c":"STORAGE", […]

Categories
Mastering Development

Can anyone help a beginner as to why this simple JS wont work?

this is a simple color change project and on the surface it looks like it should work but either the JS file isn’t loading or ive made a simple error, i cant work it out! Any help appreciated! The idea is you press the button ands the BG changes to a random hex color and […]

Categories
Database Development

Query to update one column of a table based on a column of a different table using TSQL

I have two tables with below structure : Create table Customer_info (Customer_num varchar(50), Customer_Branch int); Create table Customer_Transaction_Info (Customer_num varchar(50), Branch_Code int, Trns_Measure_One int, Trns_Measure_Two int ); Sample data for each table: insert into Customer_info(Customer_num , Customer_Branch) values(‘A’,1), (‘B’,2), (‘C’,3); Customer_num Customer_Branch ——————- ————— A 1 B 2 C 3 insert into Customer_Transaction_Info (Customer_num,Branch_Code,Trns_Measure_One,Trns_Measure_Two) Values […]

Categories
Game Creation Mastering Development

Searching for Game programmer Openings at Bangalore [closed]

I am proficient in C,C++,Data structures,Design patterns. I have 2y experience as Embedded developer. Is that good enough to apply and attend gaming industry openings. Please let me know best sites to search gaming industry openings at bangalore.

Categories
Mastering Development

How to allocate tickets

I have two files : Category: Category_File = data.frame(c("A","A","A","A","A","B","B","B","C","C","D","D")) colnames(Category_File)= c("Category") Agent: Agent_File = data.frame(c("A","A","B","B","C"),c("X","Y","X","Z","Y"),c(2,2,2,1,2)) colnames(Agent_File) = c("Category","Agent","Tickets") I need to allocate agents according to their category count. Desired Output: outputfile = data.frame(c("A","A","A","A","A","B","B","B","C","C"),c("X","X","Y","Y","NA","X","X","Z","Z","Y","NA","NA")) colnames(outputfile) = c("Category","Agent") Thanks

Categories
Mastering Development

Python Pandas improving calculation time for large datasets currently taking ~400 mins to run

I’m trying to improve performance of a DataFrame I need to build daily, and I wondered if someone had some ideas. I create a simplied example below: First, I have a dict of DataFrame‘s like this. This is time series data so updates daily. import pandas as pd import numpy as np import datetime as […]

Categories
Mastering Development

How do I make this table into a data frame? I’m using R. Trying to get the ANOVA table for it

enter image description here #Here’s what I have, but I don’t think it’s right: gas.test <- data.frame(gas=c(0, 14, 12, 13, 11, 17, 0, 13, 11, 10, 14, 14, 0, 12, 12, 13, 13, 12, 0, 11, 12, 10, 9, 8, 0), Test_Car = factor(rep(c("A","B","C","D", "E"),each=5)), Additive = factor(rep(c(1,2,3,4,5),5)))