transpose

crosstab with 2 (or more) row names

南笙酒味 提交于 2019-11-30 10:04:16
问题 I'm trying to transpose a table which has 2 row names. Postgres documentation mentions the crosstab() function being able to only handle 1 row name, but I have 2 row names, like first name and last name. my intital table is: fn | ln | file_type |attribute -------------------------------- A | 1 | cat1 |abc A | 2 | cat1 |gth A | 1 | cat2 |fgh B | 1 | cat2 |gth and I want my final table to be with 2 initial rows and the file_type transposed fn | ln | cat1 | cat2 --------------------------------

What's the difference between two way to input Matlab Complex Matrices

喜欢而已 提交于 2019-11-30 09:37:35
问题 Here's two ways to enter the command in Matlab. I don't think there's any difference between them. However, the result is really different. So I wonder what's I missed in this situation. Here's the first input: >> A = [(-0.025+0.01i) -0.025; 3 (1-2i)]; >> B = [(5.7955+1.5529i) 0]'; >> I=inv(A)*B The output is like this: I = 1.0e+02 * -0.7063 - 1.2723i -1.1030 + 1.6109i Here's the second input: >> A = [(-0.025+0.01i) -0.025;3 (1-2i)]; >> B = [(5.7955+1.5529i);0]; >> I=inv(A)*B And the Matlab

Transpose matrix multiplication in cuBLAS howto

回眸只為那壹抹淺笑 提交于 2019-11-30 07:37:13
问题 The problem is simple: I have two matrices, A and B, that are M by N, where M >> N. I want to first take the transpose of A, and then multiply that by B (A^T * B) to put that into C, which is N by N. I have everything set up for A and B, but how do I call cublasSgemm properly without it returning the wrong answer? I understand that cuBlas has a cublasOperation_t enum for transposing things beforehand, but somehow I'm not quite using it correctly. My matrices A and B are in row-major order, i

How does numpy.transpose work for this example?

ぐ巨炮叔叔 提交于 2019-11-30 07:26:10
I have difficulty understanding how numpy.transpose actually works. For example a_value = array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) and when I do np.transpose(a_value, (2, 1, 0)) I get array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]]) How can I derive this transpose manually? I need to understand the formula or the steps intuitively in the above case so I can generalize it for higher dimensions. Anand S Kumar As given in the documentation - numpy.transpose(a, axes=None) axes : list of ints, optional By default, reverse the dimensions, otherwise permute the axes according to the values given. The

How would you transpose a binary matrix?

旧城冷巷雨未停 提交于 2019-11-30 07:12:50
问题 I have binary matrices in C++ that I repesent with a vector of 8-bit values. For example, the following matrix: 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 is represented as: const uint8_t matrix[] = { 0b01010101, 0b00110011, 0b00001111, }; The reason why I'm doing it this way is because then computing the product of such a matrix and a 8-bit vector becomes really simple and efficient (just one bitwise AND and a parity computation, per row), which is much better than calculating each bit

Need to transpose a pandas dataframe

寵の児 提交于 2019-11-29 23:33:06
问题 I have a Series that look like this: col1 id 0 a 10 1 b 20 2 c 30 3 b 10 4 d 10 5 a 30 6 e 40 My desired output is this: a b c d e 10 1 1 0 1 0 20 0 1 0 0 0 30 1 0 1 0 0 40 0 0 0 0 1 I got this code: import pandas as pd df['dummies'] = 1 df_ind.pivot(index='id', columns='col1', values='dummies') I get an error: 137 138 if mask.sum() < len(self.index): --> 139 raise ValueError('Index contains duplicate entries, ' 140 'cannot reshape') 141 ValueError: Index contains duplicate entries, cannot

Transpose a datatable

旧巷老猫 提交于 2019-11-29 18:00:50
I have the data table below. I would like to change the data table to transform the data table into the one next to it. How can I do this? The reason why i would like o do this is because the excel file brings the data in like shown and then i would like to sort this data out on Row 1 Current table || Col 1 || Col 2 || Col 3 ____________________________________ Row 1 || 10 || 20 || 30 Row 2 || 1 || 2 || 3 New Datatable || Row 1 || Row 2 Col 1 || 10 || 1 Col 2 || 20 || 2 Col 3 || 30 || 3 .NET does not include a method to transpose data tables. You have to make your own. This website has a

Swap 2D array's rows and columns

依然范特西╮ 提交于 2019-11-29 16:49:25
I need to get columns from a CSV file into an array (multidimensional array or array of arrays). I used CSV.au3 which loads the rows just fine, but I need the columns in that place. My CSV file looks like: Item 1, Item 2, Another Item Item 3, Item 4 It creates a multidimensional array that looks like: $aResult[0] = [0] => 'Item 1', [1] => 'Item 2', [2] => 'Another Item' $aResult[1] = [0] => 'Item 3', [1] => 'Item 4' Where I would like it to look like: $aResult[0] = [0] => 'Item 1', [1] => 'Item 3' $aResult[1] = [0] => 'Item 2', [1] => 'Item 4' $aResult[2] = [0] => 'Another Item' For each row

Matrix multiplication in scheme, List of lists

折月煮酒 提交于 2019-11-29 16:37:51
I started to study Scheme and I do not understand some of it. I'm using DrRacket. I wrote the following code: (define mult_mat (λ (A B) (Trans_Mat (map (λ (x) (mul_Mat_vec A x)) (Trans_Mat B))))) That uses this functions: (define Trans_Mat (λ (A) (apply map (cons list A)))) (define mul_Mat_vec (λ (A v) (map (λ (x) (apply + (map * x v))) A))) In mult_mat , I multiply the matrix A in each vector of the transpose matrix B. It works fine. I found a code on the web that makes the multiplication in a way that I don't understand: (define (matrix-multiply matrix1 matrix2) (map (λ (row) (apply map (λ

Excel/VBA converts dates to American format on transpose/paste from VBA

余生颓废 提交于 2019-11-29 16:32:06
I'm working in a British context right now. Which I think I have set up in regional settings (Windows 7 in a corporate context, Excel 2016, ver 1803 (I think this may also be Office 365-? Whatever that is.)). I'm trying to work with dates in VBA and paste the results to Excel. At the beginning, and at the end, the dates are treated in UK format. But in the middle Excel insists on converting them to American. Pasting does: UK-> US -> UK. Dim p_dtTermArray() As Date ReDim p_dtTermArray(1 To lgNumTerms) p_dtTermArray(1) = DateSerial(2018, 10, 1) p_dtTermArray(2) = DateSerial(2018, 11, 1) Let's