Categories
Mastering Development

Rewriting a loop with Rccp

I am a novice Rcpp user. I want to fasten my for loop which uses several entities from r environment, and updates two vectors through iterations. The problem is that this is my first time facing c or c++ so I do not understand how to write rcpp with inline packages. Here is the reproducible […]

Categories
Mastering Development

Splitting numbers en text from the same string

I’m trying to split housenumber, box and streetnames that I get in the same String. Let’s say the string is "SomeStreet 59A" For this case I already have a solution with regex. I’m using this function: split(/([0-9]+)/) //output ["SomeStreet","59","A"] Problem I’m having now, is that some street have weird formation. Meaning it could be like […]

Categories
Mastering Development

Find all SUBSETS of a 1D array that have a specified number of UNIQUE elements (n) AND a specified sum (s)

Consider a 1D numpy array and two constants as shown: import numpy as np arr = np.arange(60) n = 5 s = 120 arr is always of the form [0,1,2,3,4, … 59,60] for example. QUESTION: From a 1D array (arr), I need to find all subsets exactly n UNIQUE elements that have a specified sum […]

Categories
Mastering Development

Changing the order of barchart in stacked bar

Data for the below code x <- structure(list(Sector = c("Agri-business", "Education & Employability", "Education & Employability", "Energy & CleanTech", "Energy & CleanTech", "Health", "Health", "Agri-business", "Agri-business", "Agri-business", "Agri-business", "Agri-business", "Education & Employability", "Education & Employability", "Energy & CleanTech", "Health", "Health", "Health", "Agri-business", "Agri-business", "Agri-business", "Education & Employability", "Education & Employability", "Energy & CleanTech", "Health", "Health", […]

Categories
Mastering Development

Why ConnectionRefusedError: [Errno 111] Connection refused on my server but not on my PC

I have created a small script to extract files from a client’s ftp, the program works correctly for me on my computer, the problem is that when I mount it on my CentoOS 7 server it rejects the connection. My code is the following: from ftplib import FTP def extract_orders_from_ftp(): with FTP(‘ftp.fake.com’) as ftp: ftp.login(‘username’, […]

Categories
Mastering Development

Dynamically explode list columns in Pandas

I have a list of dictionaries which has been converted into a dataframe using json_normalize. Dataset: x = [{ "_id" : 71, "Ids" : [ "10", "59" ], "roles" : [ "janitor", "mechanic", "technician" ] }] Dataframe: _id Ids roles 71 [10, 59] [janitor, mechanic, technician] What I am trying to do is find a […]

Categories
Arduino Ask Engineering

Help Convincing Wiimote a Nano is a WiiMotion Plus

I want to replace the outdated gyro in a wiimotion plus with a BNO055. Based off what I’ve read from wiibrew, and im currently trying to get the wiimote to recognize the nano as an extension over I2C. Theres a lot of things at play here, but this summarizes the parts related to my issue: […]

Categories
Mastering Development

Checking diagonal adjacent numbers greatest product in a grid

As mentioned in the title, I’m trying to find the greatest product of diagonal adjacent numbers in a grid but without using the numpy library. dataa = [ [1,2,3,4,5], [1,2,3,4,5], [2,3,4,5,6], [5,6,8,9,10], [1,2,3,4,5] ] def search_dr(data, length): # length = how many adjacent numbers to check result, size = 0, len(data[0]) for i in range(size): […]

Categories
Mastering Development

find frequency of numbers in intervals

What would be the most efficient way to find the frequency/count of elements in non-overlapping intervals? For example: limits = [0, 25, 40, 60] data = [15, 5, 2, 56, 45, 23, 6, 59, 33, 18] For the above lists, I want to find the number of elements in data that are within two adjacent […]

Categories
Mastering Development

Compare elements in two lists and make a new List in Dart

I have two lists and I want to make a new list by comparing the two lists and the new list should only contain those elements that contain in each of them. List1=[1,2,3,4,5,6,7,8] List2=[2,5,7,8] expectedList = [2,5,7,8] And the real code down below: "options": [ { "id": 58, "label": "cocoa", "swatch_value": null, "products": [ 118 […]