What do you want to save?
Add Code snippet
New code examples
-
Python 2021-08-31 12:07:02
rename row pandas
# if the row value in column 'is_blue' is 1 # Change the row value to 'Yes' # otherwise change it to 'No' df['is_blue'] = df['is_blue'].apply(lambda x: 'Yes' if (x == 1) else 'No') # You can also use mapping to accomplish the same result # Warning: M... Add solution -
Javascript 2021-08-30 20:55:01
javascript code to loop through array
var data = [1, 2, 3, 4, 5, 6]; // traditional for loop for(let i=0; i<=data.length; i++) { console.log(data[i]) // 1 2 3 4 5 6 } // using for...of for(let i of data) { console.log(i) // 1 2 3 4 5 6 } // using for...in for(let i in data) { con... Add solution -
Javascript 2021-08-30 03:06:01
array peremutation js recursion
const permutations = arr => { if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; return arr.reduce( (acc, item, i) => acc.concat( permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val =&g... Add solution -
Javascript 2021-08-29 09:46:02
how the map function works javascript
const posts = [ { id: 1, title: "Sample Title 1", description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit..." }, { id: 2, title: "Sample Title 2", description: "Lorem ipsum dolor sit amet, consectetur a... Add solution -
Javascript 2021-08-29 09:21:02
javascript object to array
var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0} var result = Object.keys(obj).map(function(key) ... Add solution