multiple-columns

How to do Multi-Column from_tuples?

元气小坏坏 提交于 2019-11-30 19:04:25
I get how to use pd.MultiIndex.from_tuples() in order to change something like Value (A,a) 1 (B,a) 2 (B,b) 3 into Value Caps Lower A a 1 B a 2 B b 3 But how do I change column tuples in the form (A, a) (A, b) (B,a) (B,b) index 1 1 2 2 3 2 2 3 3 2 3 3 4 4 1 into the form Caps A B Lower a b a b index 1 1 2 2 3 2 2 3 3 2 3 3 4 4 1 Many thanks. Edit: The reason I have a tuple column header is that when I joined a DataFrame with a single level column onto a DataFrame with a Multi-Level column it turned the Multi-Column into a tuple of strings format and left the single level as single string. Edit

replacing values in a column with another column R

怎甘沉沦 提交于 2019-11-30 16:06:17
问题 I have two tables in different dimensions, now I want to replace value datA$swl1 with values in datB$swl2 according to userids. datA id swl1 1 0.8 2 0.7 3 0.4 4 0.7 5 0.0 datB id swl2 1 0.8 3 0.6 5 0.7 output datA (here swl1 is replaced by the new values in swl2, but not all the ids have a new values, for those that haven't, the original values are retained) id swl1 1 0.8 2 0.7 3 0.6 4 0.7 5 0.7 how to do this? 回答1: You can use merge to match by id , then replace in column swl1 those items

Twitter Bootstrap Responsive - Show Table Column only on Desktop

百般思念 提交于 2019-11-30 13:59:33
问题 I'm using DataTables.net + Twitter Bootstrap and the responsive layout, what I'm trying is to hide some columns of the table using the class "visible-desktop" thats shows the columns only in big sizes but It seems not to work, hides well but if I resize the windows to get a desktop width the columns hidden start showing stacked, seems a CSS display class problem, because inherits the type of display from the parent: .visible-desktop { display: inherit!important; } If I manipulate it to

Combine multiple rows into multiple columns dynamically in SQL Server

放肆的年华 提交于 2019-11-30 12:04:39
问题 I have a large database table on which I need to perform the action below dynamically using Microsoft SQL Server. From a result like this: badge | name | Job | KDA | Match - - - - - - - - - - - - - - - - T996 | Darrien | AP | 3.0 | 20 T996 | Darrien | ADC | 2.8 | 16 T996 | Darrien | TOP | 5.0 | 120 To a result like this using SQL: badge | name | AP_KDA | AP_Match | ADC_KDA | ADC_Match | TOP_KDA | TOP_Match - - - - - - - - - T996 | Darrien | 3.0 | 20 | 2.8 | 16 | 5.0 | 120 Even if there are 30

BATCH Multiple Image Printing on Single Sheet

馋奶兔 提交于 2019-11-30 09:58:56
问题 I got 1000's of images on a folder & I wanna resize & print 12 to 24 images per sheet.Using BATCH script to collect images from a folder and output an HTML script with 3 colums & 6 rows per page , open in firefox (shrink to fit &print) . how to add filename, date on every image on html script. del "c:\zz.html" setlocal EnableDelayedExpansion set /a "p=1" set /a "m=2" set /a "w=4" echo ^<table cellspacing="5" style="border:1px solid black;"^> >>"c:\zz.html" for /f "delims=" %%i in ('dir /s/b

How to split data frame by column names in R?

本秂侑毒 提交于 2019-11-30 08:53:05
问题 My 24 hours of search for what I feel is a trivial (Not for a newbie in R as I am) problem has not yet born fruits. So please help me out. I have a single data frame that I would wish to split into two. Here is how the data looks like; d1 d2 d3 d4 p1 p2 p3 p4 30 40 20 60 1 3 2 5 20 50 40 30 3 4 1 5 40 20 50 30 2 3 1 4 here is what I want it to look like; $d d1 d2 d3 d4 30 40 20 60 20 50 40 30 40 20 50 30 $p p1 p2 p3 p4 1 3 2 5 3 4 1 5 2 3 1 4 I have tried to most of the commands and examples

Color escape codes in pretty printed columns

那年仲夏 提交于 2019-11-30 08:29:52
问题 I have a tab-delimited text file which I send to column to "pretty print" a table. Original file: 1<TAB>blablablabla<TAB>aaaa bbb ccc 2<TAB>blabla<TAB>xxxxxx 34<TAB>okokokok<TAB>zzz yyy Using column -s$'\t' -t <original file> , I get 1 blablablabla aaaa bbb xxx 2 blabla xxxxxx 34 okokokok zzz yyy as desired. Now I want to add colors to the columns. I tried to add the escape codes around each tab-delimited field in the original file. column successfully prints in color, but the columns are no

How to drop columns which have same values in all rows via pandas or spark dataframe?

女生的网名这么多〃 提交于 2019-11-30 08:06:28
Suppose I've data similar to following: index id name value value2 value3 data1 val5 0 345 name1 1 99 23 3 66 1 12 name2 1 99 23 2 66 5 2 name6 1 99 23 7 66 How can we drop all those columns like ( value , value2 , value3 ) where all rows have same values, in one command or couple of commands using python ? Consider we have many columns similar to value , value2 , value3 ... value200 . Output: index id name data1 0 345 name1 3 1 12 name2 2 5 2 name6 7 EdChum What we can do is apply nunique to calc the number of unique values in the df and drop the columns which only have a single unique value:

How to paste columns from separate files using bash?

怎甘沉沦 提交于 2019-11-30 05:38:30
Using the following data: $cat date1.csv Bob,2013-06-03T17:18:07 James,2013-06-03T17:18:07 Kevin,2013-06-03T17:18:07 $cat date2.csv 2012-12-02T18:30:31 2012-12-02T18:28:37 2013-06-01T12:16:05 How can date1.csv and date2.csv files be merged? Output desired: $cat merge-date1-date2.csv Bob,2013-06-03T17:18:07,2012-12-02T18:30:31 James,2013-06-03T17:18:07,2012-12-02T18:28:37 Kevin,2013-06-03T17:18:07,2013-06-01T12:16:05 Please note: the best solution will be able to quickly manage a massive number of lines. You were on track with paste(1) : $ paste -d , date1.csv date2.csv Bob,2013-06-03T17:18:07

Remove rows in python less than a certain value

寵の児 提交于 2019-11-30 04:49:17
I feel like this question must have been answered by someone before, but I can't find an answer on stack overflow! I have a dataframe result that looks like this and I want to remove all the values less than or equal to 10 >>> result Name Value Date 189 Sall 19.0 11/14/15 191 Sam 10.0 11/14/15 192 Richard 21.0 11/14/15 193 Ingrid 4.0 11/14/15 This command works and removes all the values that are 10: df2 = result[result['Value'] != 10] But when I try to add the <= qualifier I get the error message SyntaxError: invalid syntax df3 = result[result['Value'] ! <= 10] I feel like there is probably a