transpose

Turning one row into multiple rows in r [duplicate]

随声附和 提交于 2021-02-19 02:44:09
问题 This question already has answers here : Combine Multiple Columns Into Tidy Data [duplicate] (3 answers) Closed 3 years ago . In R, I have data where each person has multiple session dates, and the scores on some tests, but this is all in one row. I would like to change it so I have multiple rows with the persons info, but only one of the session dates and corresponding test scores, and do this for every person. Also, each person may have completed different number of sessions. Ex: ID Name

Transpose of a matrix in numpy

三世轮回 提交于 2021-02-16 16:18:09
问题 I have this numpy array: a = np.array([[[1,2,3],[-1,-2,-3]],[[4,5,6],[-4,-5,-6]]]) b is a transpose of a . I want b be like this: b = np.array([[[1,-1],[2,-2],[3,-3]],[[4,-4],[5,-5],[6,-6]]]) Is it possible to do it in one line? EDIT: And if I have this instead: a = np.empty(3,dtype = object) a[0] = np.array([[1,2,3],[-1,-2,-3]]) a[1] = np.array([[4,5,6],[-4,-5,-6]]) How can I get b? 回答1: You can do it using np.transpose(a,(0,2,1)) : In [26]: a = np.array([[[1,2,3],[-1,-2,-3]],[[4,5,6],[-4,-5

Transpose the data in a column every nth rows in PANDAS

心不动则不痛 提交于 2021-02-16 07:52:31
问题 For a research project, I need to process every individual's information from the website into an excel file. I have copied and pasted everything I need from the website onto a single column in an excel file, and I loaded that file using PANDAS. However, I need to present each individual's information horizontally instead of vertically like it is now. For example, this is what I have right now. I only have one column of unorganized data. df= pd.read_csv("ior work.csv", encoding = "ISO-8859-1"

Transpose the data in a column every nth rows in PANDAS

半城伤御伤魂 提交于 2021-02-16 07:49:21
问题 For a research project, I need to process every individual's information from the website into an excel file. I have copied and pasted everything I need from the website onto a single column in an excel file, and I loaded that file using PANDAS. However, I need to present each individual's information horizontally instead of vertically like it is now. For example, this is what I have right now. I only have one column of unorganized data. df= pd.read_csv("ior work.csv", encoding = "ISO-8859-1"

How to swap rows and columns of a 2d array?

早过忘川 提交于 2021-02-15 06:48:52
问题 I'm trying to write a method for 'transpose' a two-dimensional array of integers, in which the rows and columns of the original matrix are exchanged. However, I have no idea how I can realize this. How do I write out this method? public class Matrix { private int[][] numbers; public Matrix(int rows, int colums) { if (rows < 1) rows = 1; else rows = rows; if (colums < 1) colums = 1; else colums = colums; numbers = new int[rows][colums]; } public final void setNumbers(int[][] numbers) { this

Transposing Data in Pandas

只谈情不闲聊 提交于 2021-02-11 15:15:55
问题 I have an excel file that contains a count of how many times an Part has been used during its lifespan. The data is currently stored in such a way that the Serial numbers are in Column A, and each "Lifespan" Count is stored in adjacent columns, with a "Date" value as its heading. Here is an example: Image1 I want to be able to pivot/transpose ALL of the Date columns in Python so that the output is in the following format with the Lifespan Count as a new column named "Count": Image2 I've tried

Split Google Sheets Query results from one row into two

半城伤御伤魂 提交于 2021-02-10 14:30:55
问题 I want to take my QUERY results and move one cell (H [description]) to the following row of each result. I found this answer, which is very close, but the format of the table is different, so I'm not sure how to apply it to my scenario. This is the basic idea: Category | Sub-Category | Item | Description Fruit | Citrus | Orange | It's orange Fruit | Melon | Cantaloupe | Round Into Category | Sub-Category | Item Fruit | Citrus | Orange It's orange Fruit | Melon | Cantaloupe Round 回答1:

How to transpose sheet with POI SS/XSSF?

青春壹個敷衍的年華 提交于 2021-02-07 13:48:03
问题 I am using POI XSSF API and I would like to transpose a sheet. how can I do that? Thanks. 回答1: Transpose, as in swap A2 with B1 and A3 with C1 (so columns become rows)? If so, there's nothing built in, so you'd need to do a little bit of coding yourself. You'd likely want to grab a pair of cells, save the contents of one (value and style), copy the second to the first, then overwrite the second. See the quick guide if you're not sure on all the reading/writing parts. 回答2: I was looking for

How to transpose sheet with POI SS/XSSF?

浪子不回头ぞ 提交于 2021-02-07 13:46:27
问题 I am using POI XSSF API and I would like to transpose a sheet. how can I do that? Thanks. 回答1: Transpose, as in swap A2 with B1 and A3 with C1 (so columns become rows)? If so, there's nothing built in, so you'd need to do a little bit of coding yourself. You'd likely want to grab a pair of cells, save the contents of one (value and style), copy the second to the first, then overwrite the second. See the quick guide if you're not sure on all the reading/writing parts. 回答2: I was looking for

Transpose a single column to multiple rows

好久不见. 提交于 2021-02-05 12:19:38
问题 I have one column of data with approximately 800 records. Each 18 cells is one record. I need a script that takes every 18 cells and transposes them to a row dynamically, or even a way to write excel formula to transpose every 18 records from the column to a row. 回答1: You'll probably get asked "what have you tried" since it's preferred that you have a bash at it and ask when you get stuck rather than asking for a complete solution. That having been said, I can offer you some tips to get you