convert a pyspark dataframe column in databricks as a list without using rdd

Advertisements I trying to collect the values of a pyspark dataframe column in databricks as a list. When I use the collect function df.select(‘col_name’).collect() , I get a list with extra values. based on some searches, using .rdd.flatmap() will do the trick However, for some security reasons (it says rdd is not whitelisted), I cannot… Read More convert a pyspark dataframe column in databricks as a list without using rdd

How to extract a specific substring (based on regex) from an array of strings

Advertisements I have a big array of strings: [‘{{Wanted Value}}’, ‘true’, ‘{{Wanted Value}}’, ‘{{Wanted Value}} unwanted {{Wanted Value}}’, ‘false’…] I want to filter the array and extract every {{Wanted Value}} substring to a new array. If the item in the array contains 2 or more of these substrings, I want to have each of them… Read More How to extract a specific substring (based on regex) from an array of strings

Not getting all the keys of nested object using Javascript

Advertisements I am trying to fetch all the keys of one nested object using Javascript but as per my code its not working as expected. I am explaining my code below. let jsonObj = { “service”:[ { “name”:”restservice”, “device”:”xr-1″, “interface-port”:”0/0/2/3″, “interface-description”:”uBot testing for NSO REST”, “addr”:”10.10.1.3/24″, “mtu”:1024 } ], “person”: { “male”: { “name”: “infinitbility”… Read More Not getting all the keys of nested object using Javascript

Nested map function resulting in a TypeError after finishing execution

Advertisements code: window.reddit.comments("uq0mzi").sort(‘hot’).fetch(function(res) { res[1].data.children.flatMap((item) => { console.log(item.data.body) item.data.replies.data.children.map(y => (y.data.body === undefined ? "" : console.log(" >>>"+y.data.body))) })}) what I’m trying: I’m using the reddit API wrapper to get comments and their replies of a post. first map prints out the top level comments, while the second map is supposed to print out the… Read More Nested map function resulting in a TypeError after finishing execution

Perform stream operation on the sub-lists inside a List<List<Integer>>

Advertisements I have a Student class: public class Student { private String name; private String marks; private List<Integer> percent; } There is a List defined as below in another class: stud1.setMarks("20"); stud1.setName("Sumit"); stud1.setRollNo(1); stud1.setPercent(Arrays.asList(20,30,40)); stud2.setMarks("50"); stud2.setName("Thakur"); stud2.setRollNo(2); stud2.setPercent(Arrays.asList(25,35,45)); stud3.setMarks("70"); stud3.setName("Dhawan"); stud3.setRollNo(3); stud3.setPercent(Arrays.asList(50,60)); List<Student> list = new ArrayList<Student>(); list.add(stud1); list.add(stud2); list.add(stud3); I want to perform operation… Read More Perform stream operation on the sub-lists inside a List<List<Integer>>

Javascript: How to populate arguments passed to a function?

Advertisements I have this code that returns cartesian product of three arrays: function getcartesianProduct(symbols: Array<string>) { const cartesian = <T,>(…sets: T[][]) => sets.reduce<T[][]>((accSets, set) => accSets.flatMap(accSet => set.map(value => […accSet, value])), [[]]); return cartesian(symbols, symbols, symbols).map((items: Array<string>) => items.join("")); } For example, like this: >> const numbers: Array<string> = "0123456789".split(""); >> getcartesianProduct(numbers).slice(0, 5) ["000", "001",… Read More Javascript: How to populate arguments passed to a function?