multiple-columns

Order parent child records by parent group and children

一世执手 提交于 2019-12-01 19:28:57
问题 I need sort query results by specific two related columns. My table is: Row no | Col 1 | Col 2 | Col 3 | Col 4 1 | 1 | X | 1 | 5 2 | 2 | Y | 1 | 6 3 | 5 | Z | 2 | 7 4 | 6 | T | 2 | 0 5 | 7 | T | 3 | 0 6 | 6 | W | 2 | 0 The values in Col 4 represents the child record linked to Col 1 . So for Row no = 1 the next child record is row 3, where Col 1 holds the value of Col 4 from the first row. The next child row for row 3 is row 5, based on the link between Col 1 and Col 4 . And I'd like to return

How to plot single/multiple lines depending on values in a column with GNUPlot

寵の児 提交于 2019-12-01 18:43:59
I have a little problem using gnuplot. Here is my datafile: From Time Packets Jitter 127.0.0.1:53091 1 0 274 127.0.0.1:53091 2 0 417 127.0.0.1:53091 3 36 53 127.0.0.1:53091 4 215 55 127.0.0.1:53090 4 215 55 127.0.0.1:53091 5 215 33 127.0.0.1:53090 6 256 78 (I put that "time" for the test, but it will be replaced by a datetime after it works) I want to draw two different graphics, with Time column in x axis on both, and Packets column (on a first graphic) & Jitter column (on a second graphic) in y axis. But, as you may have seen, I don't know how many different values from the From column I

CSS columns: target last child in each column?

时间秒杀一切 提交于 2019-12-01 17:31:10
I have a grid of headlines in newspaper format using CSS3 column count. http://jsfiddle.net/L6TTJ/ HTML: <ul> <li><h3><a href='#'>heading</a></h3><p>snippet</p></li> <li><h3><a href='#'>heading</a></h3><p>snippet</p></li> <!-- ... etc ... --> </ul> CSS (vendor prefixes and non-pertinent rules omitted for brevity) : ul { column-count: 3; column-rule: 1px solid #ccc; } li { border-bottom: solid 1px #ccc; } You can see where this is going: is there any means in CSS to target the last li element in each column so I can remove the bottom border? I found this question , but there's no answer. I

Filter rows based on multiple column conditions R

▼魔方 西西 提交于 2019-12-01 16:28:34
问题 Suppose I have a dataset that has 100-odd columns and I need to keep only those rows in the data which meets one condition applied across all 100 columns.. How do I do this? Suppose, its like below... I need to only keep rows where either of Col1 or 2 or 3 or 4 is >0 Col1 Col2 Col3 Col4 1 1 3 4 0 0 4 2 4 3 4 3 2 1 0 2 1 2 0 3 0 0 0 0 In above example, except last row all rows will make it .. I need to place results in same dataframe as original. not sure if I can use the lapply to loop

Pandas: Is there a way to use something like 'droplevel' and in process, rename the the other level using the dropped level labels as prefix/suffix?

会有一股神秘感。 提交于 2019-12-01 16:07:57
Screenshot of the query below: Is there a way to easily drop the upper level column index and a have a single level with labels such as points_prev_amax , points_prev_amin , gf_prev_amax , gf_prev_amin and so on? Use list comprehension for set new column names: df.columns = df.columns.map('_'.join) Or: df.columns = ['_'.join(col) for col in df.columns] Sample: df = pd.DataFrame({'A':[1,2,2,1], 'B':[4,5,6,4], 'C':[7,8,9,1], 'D':[1,3,5,9]}) print (df) A B C D 0 1 4 7 1 1 2 5 8 3 2 2 6 9 5 3 1 4 1 9 df = df.groupby('A').agg([max, min]) df.columns = df.columns.map('_'.join) print (df) B_max B_min

Pandas: Is there a way to use something like 'droplevel' and in process, rename the the other level using the dropped level labels as prefix/suffix?

可紊 提交于 2019-12-01 15:00:44
问题 Screenshot of the query below: Is there a way to easily drop the upper level column index and a have a single level with labels such as points_prev_amax , points_prev_amin , gf_prev_amax , gf_prev_amin and so on? 回答1: Use list comprehension for set new column names: df.columns = df.columns.map('_'.join) Or: df.columns = ['_'.join(col) for col in df.columns] Sample: df = pd.DataFrame({'A':[1,2,2,1], 'B':[4,5,6,4], 'C':[7,8,9,1], 'D':[1,3,5,9]}) print (df) A B C D 0 1 4 7 1 1 2 5 8 3 2 2 6 9 5

How do you combine two columns into a new column in a dataframe made of two or more different csv files?

廉价感情. 提交于 2019-12-01 14:44:13
I have several csv files all named with dates and for all of them I want to create a new column in each file that contains data from two other columns placed together. Then, I want to combine them into one big dataframe and choose only two of those columns to keep. Here's an example: Say I have two dataframes: a b c a b c x 1 2 3 x 3 2 1 y 2 3 1 y 2 1 3 Then I want to create a new column d in each of them: a b c d a b c d x 1 2 3 13 x 3 2 1 31 y 2 3 1 21 y 2 1 3 23 Then I want to combine them like this: a b c d x 1 2 3 13 y 2 3 1 21 x 3 2 1 31 y 2 1 3 23 Then keep two of the columns a and d

How do you combine two columns into a new column in a dataframe made of two or more different csv files?

痴心易碎 提交于 2019-12-01 12:33:08
问题 I have several csv files all named with dates and for all of them I want to create a new column in each file that contains data from two other columns placed together. Then, I want to combine them into one big dataframe and choose only two of those columns to keep. Here's an example: Say I have two dataframes: a b c a b c x 1 2 3 x 3 2 1 y 2 3 1 y 2 1 3 Then I want to create a new column d in each of them: a b c d a b c d x 1 2 3 13 x 3 2 1 31 y 2 3 1 21 y 2 1 3 23 Then I want to combine them

One query to insert multiple rows with multiple columns

陌路散爱 提交于 2019-12-01 11:02:31
问题 Let's say I want to insert this data: Row 1: People = '40', Places = '15' Row 2: People = '5', Places = '10' I understand that this is how you'd execute the above: mysql_query("INSERT INTO mytable(`People`, `Places`) VALUES ('40', '15'),('5', '10')"); But what if I wanted to insert into more than two columns with a single query? What if the data to be inserted was like this: Row 1: People = '40', Places = '15' Row 2: People = '5', Places = '10' Row 3: Things = '140', Ideas = '20' Row 4:

R:Extracting words from one column into different columns

Deadly 提交于 2019-12-01 08:38:18
I've been figuring this out for a couple of hours now. Let's say I have a column with 1-4 words, separated by space: aba bkak absbs a2aj akls bios sad fasa lgk . . . I would like those words to be in separate columns, for easier further processing. SO instead those words are in one column, how do I get them to separate columns? Thanks for any help. Try library(splitstackshape) cSplit(df1, 'V1', ' ') Or library(tidyr) separate(df1, 'V1', paste0('V', 1:4), sep= ' ', extra='drop') Or using base R read.table(text=df1$V1, sep=' ', fill=TRUE) NOTE: Used the column name as 'V1' and dataset as 'df1'