transpose

Transpose select results with Oracle

自古美人都是妖i 提交于 2019-11-27 07:20:34
问题 my question is, with some background: I have to generate some sql queries based on the table metadata (column format), and the result is something like: TABLENAME1|COL1 TABLENAME1|COL2 TABLENAME2|COL1 TABLENAME2|COL2 TABLENAME2|COL3 TABLENAME3|COL1 TABLENAME4|COL1 TABLENAME4|COL2 ... /*some other 1800 rows */ (Yeah, it's ordered.) What I need is to transpose this data, based on the first column, so the expected output would be: TABLENAME1|COL1|COL2|NULL TABLENAME2|COL1|COL2|COL3 TABLENAME3

Transpose a matrix in racket (list of lists

百般思念 提交于 2019-11-27 06:15:13
问题 I got a list of lists in racket and have to transpose them. (: transpose ((list-of(list-of %a)) -> (list-of (list-of %a)))) (check-expect (transpose (list (list 1 2 3) (list 4 5 6))) (list (list 1 4) (list 2 5) (list 3 6))) (define transpose (lambda (xs) (cond ((empty? xs)empty) ((pair? xs)(make-pair (make-pair (first(first xs)) (make-pair (first(first(rest xs)))empty)) (transpose (rest(rest xs)))))))) That's my code at the moment. I think the problem is in the recursive call (correct me if I

Transpose array and actually reorder memory

守給你的承諾、 提交于 2019-11-27 05:57:04
问题 I have a 3-D NumPy array, e.g. a = np.random.random((2,3,5)) I would like to transpose the last two axes, i.e. b = a.transpose(0,2,1) However, I do not want a view with twiddled strides! I want to actually copy the array and reorder it in memory . What is the best way to achieve this? 回答1: The copy() method will reorder to C-contiguous order by default: b = a.transpose(0,2,1).copy() 回答2: Under the hood, the stride of b is different than a. prefer to use ascontiguousarray, which will copy the

How to transpose rows to columns with large amount of the data in BigQuery/SQL?

谁都会走 提交于 2019-11-27 05:37:46
I have a problem in transposing a large amount of data table in BigQuery (1.5 billion rows) from rows to columns. I could figure out how to do it with small amount of data when hardcoded, but with this large amount. A snapshot of the table looks like this: +--------------------------+ | CustomerID Feature Value | +--------------------------+ | 1 A123 3 | | 1 F213 7 | | 1 F231 8 | | 1 B789 9.1 | | 2 A123 4 | | 2 U123 4 | | 2 B789 12 | | .. .. .. | | .. .. .. | | 400000 A123 8 | | 400000 U123 7 | | 400000 R231 6 | +--------------------------+ So basically there are approximately 400,000 distinct

SQL to transpose row pairs to columns in MS ACCESS database

戏子无情 提交于 2019-11-27 03:32:07
问题 I have an MS Access database that contains translated sentences in source-target pairs (a translation memory for fellow users of CAT tools). Somewhat annoyingly, source and target are not stored in separate columns, but in rows linked by ID, like this: +---+----+--------------+ |id |lang| text | +---+----+--------------+ 1 a lang a text 1 b lang b text 2 a more a text... 2 b more b text... +---+----+--------------+ What SQL could I use to turn that into a table such as: +---+--------------+--

Excel VBA - Range.Copy transpose paste

喜夏-厌秋 提交于 2019-11-27 02:05:39
I'm trying to something very simple, but I seem to be stuck. I am following the help menu for PasteSpecial but I cannot seem to get my code to work without an error. I want to take Worksheets("Sheet1").Range("A1","A5") and paste transpose to Worksheets("Sheet2").Range("A1","E1") . What is the most simple way to accomplish this? Worksheets("Sheet1").Range("A1:A5").Copy Worksheets("Sheet2").Range("A1").PasteSpecial Transpose:=True 来源: https://stackoverflow.com/questions/8852717/excel-vba-range-copy-transpose-paste

Convert row to column in Python Pandas

↘锁芯ラ 提交于 2019-11-27 01:27:22
I have the following Python pandas dataframe: fruits | numFruits --------------------- 0 | apples | 10 1 | grapes | 20 2 | figs | 15 I want: apples | grapes | figs ----------------------------------------- Market 1 Order | 10 | 20 | 15 I have looked at pivot(), pivot_table(), Transpose and unstack() and none of them seem to give me this. Pandas newbie, so all help appreciated. You need set_index with transpose by T : print (df.set_index('fruits').T) fruits apples grapes figs numFruits 10 20 15 If need rename columns, it is a bit complicated: print (df.rename(columns={'numFruits':'Market 1

How to pivot a dataframe in Pandas? [duplicate]

非 Y 不嫁゛ 提交于 2019-11-26 22:52:25
This question already has an answer here: How to pivot a dataframe 1 answer I have a table in csv format that looks like this. I would like to transpose the table so that the values in the indicator name column are the new columns, Indicator Country Year Value 1 Angola 2005 6 2 Angola 2005 13 3 Angola 2005 10 4 Angola 2005 11 5 Angola 2005 5 1 Angola 2006 3 2 Angola 2006 2 3 Angola 2006 7 4 Angola 2006 3 5 Angola 2006 6 I would like the end result to like like this: Country Year 1 2 3 4 5 Angola 2005 6 13 10 11 5 Angola 2006 3 2 7 3 6 I have tried using a pandas data frame with not much

How can I turn part of the Excel data to columns to get a desired output?

倖福魔咒の 提交于 2019-11-26 22:09:58
问题 For eg - Say I have data in the following format - Current Format I would need the data to be formatted in the following format for ease of use - Required Format Of course the data contains a lot more records - I'm looking for an easy way to transpose data in this way for large sets of data. Any help will be appreciated :) 回答1: This is very easy with PowerQuery. It is inbuilt for Excel 2016 and a freely available add in for Version from 2010 to 2013. You would set your data up as a table

Results transposed with R apply [duplicate]

二次信任 提交于 2019-11-26 22:08:34
问题 This question already has an answer here : Why apply() returns a transposed xts matrix? (1 answer) Closed 6 years ago . Apologies, I just realised that this has already been answered here. This should be pretty basic but I do not really understand why it is happening. Can someone help? This is the simple code with the example 'data': applyDirichletPrior <- function (row_vector) { row_vector_added <- row_vector + min (row_vector) row_vector_result <- row_vector_added / sum(row_vector_added) }