transpose

Excel - transpose pairs of columns

守給你的承諾、 提交于 2019-12-11 12:36:15
问题 I'm attempting to transpose - if that's the right application of the term - pairs of columns into repeating rows. In concrete terms, I need to go from this: Thing1 6 0.29 5 0.23 7 0.19 8 0.11 to this: Thing1 6 0.29 Thing1 5 0.23 Thing1 7 0.19 Thing1 8 0.11 This operation will occur with at least 7 pairs of columns for several hundred "things." The part I can't figure out is how to group/lock the pairs to be treated as one unit. In some ways, I'm trying to do the opposite of what is normally

EmptyDataError while writing and reading from temporary file in Python

前提是你 提交于 2019-12-11 09:48:02
问题 I am converting one file format into another file format by creating a temporary intermediate file. Following are my codes: import tempfile import pandas as pd from pandas import DataFrame def convert_binary_step1(file1,file2,file3): source=open(file1) SampleList=convert_file_to_list(file2) dest=open(file3,'w') ti= tempfile.NamedTemporaryFile(delete=False) l=[] for line in source: a=line.split() del a[-1] for i in range(len(SampleList)): if SampleList[i] in a: l.append("1") else: l.append("0"

How to pivot a dataframe with pandas so variable columns become rows?

拈花ヽ惹草 提交于 2019-12-11 07:26:01
问题 I currently have the following dataframe: Current df : type part number part description waiting period hours 0 service item SOME-X1R-1807 SOME 1 day 24 1 CONSUMABLE RANDOM-462-1171 DESCRIPTION 6 days 144 2 wheel PART-7W-2326 ABOUT THE 7 days 168 3 tyre NUMBER-1R-0762 PARTS FROM THE 8 days 192 4 other NUMBER-XL-0747 PREVIOUS COLUMN 9 days 216 I want to pivot the table, and get the following outcome: Expected df : SOME-X1R-1807 RANDOM-462-1171 PART-7W-2326 NUMBER-1R-076 NUMBER-XL-0747 part

Excel transpose formula

◇◆丶佛笑我妖孽 提交于 2019-12-11 07:08:31
问题 I've been wraping my head around it for some time and just don't know how to approach this problem. My table consists of groups of data which I want to transpose from rows to columns. Every row has an index number in first column and all of the rows in one group have the same index. 1 a 1 b 1 c 1 d 1 e 1 f 1 g 1 h 2 as 2 bs 2 cs 5 ma 5 mb 5 mc 5 md and I want my final result to be: 1 a b c d e f g h 2 as bs cs 5 ma mb mc md is it possible to do this with formulas or do I have to do it in VBA?

Matrix Transpose Common Lisp

爷,独闯天下 提交于 2019-12-11 05:24:50
问题 Well, i've been told to make a Matrix Transpose function in common lisp. I'm a beginner, so i don't know so much of it. My Matrix is a list of lists, and i can't use apply, mapcar or similar to solve it, just CONS, CAR and CDR. If not, my solution would be this (I put this solution so someone can use it): (DEFUN transpose (List) (apply #'mapcar #'list List) ) But I can't use anything of the above. The function has to be recursive, no loops or similar. So, the question is, how could this be

Transpose CSV data with awk (pivot transformation)

怎甘沉沦 提交于 2019-12-11 02:47:00
问题 my CSV data looks like this: Indicator;Country;Value no_of_people;USA;500 no_of_people;Germany;300 no_of_people;France;200 area_in_km;USA;18 area_in_km;Germany;16 area_in_km;France;17 proportion_males;USA;5.3 proportion_males;Germany;7.9 proportion_males;France;2.4 I want my data to look like this: Country;no_of_people;area_in_km;proportion_males USA;500;18;5.3 Germany;300;16;7.9 France;200;17;2.4 There are more Indicators and more countries than listed here. Pretty large files (number of

An efficient way to transpose a file in Bash

你说的曾经没有我的故事 提交于 2019-12-11 02:33:12
问题 I have a huge tab-separated file formatted like this X column1 column2 column3 row1 0 1 2 row2 3 4 5 row3 6 7 8 row4 9 10 11 I would like to transpose it in an efficient way using only bash commands (I could write a ten or so lines Perl script to do that, but it should be slower to execute than the native bash functions). So the output should look like X row1 row2 row3 row4 column1 0 3 6 9 column2 1 4 7 10 column3 2 5 8 11 I thought of a solution like this cols=`head -n 1 input | wc -w` for (

Data Wrangling in Excel - Rearranging Columns and Rows

僤鯓⒐⒋嵵緔 提交于 2019-12-11 01:55:11
问题 I have a massive dataset in excel. I would like to rearrange the rows and columns. Here's a snippet of the data, what it looks like and what I'd like it to look like under. Area, Channel, Unit, Year1, Year2, Year3, Year4 bel, dc, share, 25, 36, 56, 45 bel, dc, avm, 23, 45, 65, 47, bel, dc, ats, 45, 2, 3, 4, bel, tl, share, 25, 36, 56, 45 bel, tl, avm, 23, 45, 65, 47, bel, tl, ats, 45, 2, 3, 4, I'd like to switch Unit and the Years (Year1, Year2, Year3, Year4). To look like this Area, Chennel,

Fortran reshape - N-dimensional transpose

自闭症网瘾萝莉.ら 提交于 2019-12-10 20:34:39
问题 I'm trying to write some code in Fortran which requires the re-ordering of an n-dimensional array. I thought the reshape intrinsic combined with the order argument should allow this, however I'm running into difficulties. Consider the following minimal example program test implicit none real, dimension(:,:,:,:,:), allocatable :: matA, matB integer, parameter :: n1=3, n2=5, n3=7, n4=11, n5=13 integer :: i1, i2, i3, i4, i5 allocate(matA(n1,n2,n3,n4,n5)) !Source array allocate(matB(n3,n2,n4,n1

Transpose in Elm without Maybe

爱⌒轻易说出口 提交于 2019-12-10 18:38:04
问题 I have a list of lists of ints [[1,2,3,4],[1,2,3,4]] I want to transpose that to [[1,1],[2,2],[3,3]...] I have: transpose : List (List a) -> List (List a) transpose ll = case ll of ((x::xs)::xss) -> (x :: (List.map List.head xss)) :: transpose (xs :: (List.map List.tail xss)) otherwise -> [] but the issue is that the compiler doesn't like the head and tail operations and wants to return a Maybe type. How do I transpose a list properly in elm? 回答1: It depends... Do you want to do this