Make all possible combinations of arrays

Lets say you have an multidimensional array a = np.array([[1, 2], [3, 5], [4,5], [9,5]]) I want all the possible combinations of two arrays given the multidimensional array "a" so that: [[1, 2],[3, 5]] , [[1, 2],[4,5]] … I have no idea how to due this. Does someone have some suggestions and tips? >Solution :… Read More Make all possible combinations of arrays

How to use python and SQL to delete the combination of numbers and letters at the end but keep the numbers in other place?

I need to do a regex using python and SQL respectively. If I have 3 strings like: aaa bbb 1234 cc d e ff fji1223 345 aaa bbb feij sdkj 434343 458iui3 48 aaa bbb 1234 fjie skfj The above are three strings. I want to delete the combinations of numbers and letters, or just… Read More How to use python and SQL to delete the combination of numbers and letters at the end but keep the numbers in other place?

What is the relationship between the product function and the concept of permutations with repetitions?

from itertools import permutations,product,combinations_with_replacement colours = [‘r’,’g’,’b’] y = list(product(colours,repeat =2 )) x = list(combinations_with_replacement(colours,2)) print(y) print(x) I understand permutation of a set of objects is an ordering of those objects. When some of those objects are identical, the situation is transformed into permutations with repetition. >Solution : This may provide some insight: colours =… Read More What is the relationship between the product function and the concept of permutations with repetitions?

Pick a column value based on column index stored in another column (Pandas)

Let’s say we have four columns: Column1, Column2, Column3, ind import pandas as pd tbl = { ‘Column1’:[‘Spark’,10000,’Python’,’35days’], ‘Column2′ :[500,’PySpark’,22000,30000], ‘Column3′:[’30days’,’40days’,’35days’,’pandas’], ‘ind’:[1,2,1,3] } df = pd.DataFrame(tbl) Does anyone know is there a way to add a new column without loop that will gather values from first 3 columns based on index stored in ‘ind’ column?… Read More Pick a column value based on column index stored in another column (Pandas)

function to output pairwise of passed letters

I would like to create a python function, that can take in letters and output a pairwise comparison of the letter given. So for example, if my function is named pairwise_letters(), then it should behave as follows: >>> pairwise_letters(‘AB’) AB >>> pairwise_letters(‘ABC’) AB BC AC >>> pairwise_letters(‘ABCD’) AB BC CD AC BD AD >>> pairwise_letters(‘ABCDE’)… Read More function to output pairwise of passed letters