multiple-columns

mysql table with 40+ columns

巧了我就是萌 提交于 2019-12-04 04:25:39
问题 I have 40+ columns in my table and i have to add few more fields like, current city, hometown, school, work, uni, collage.. These user data wil be pulled for many matching users who are mutual friends (joining friend table with other user friend to see mutual friends) and who are not blocked and also who is not already friend with the user. The above request is little complex, so i thought it would be good idea to put extra data in same user table to fast access, rather then adding more joins

Select column 2 to last column in R

时光毁灭记忆、已成空白 提交于 2019-12-04 03:54:09
I have a data frame with multiple columns. Now, I want to get rid of the row.names column (column 1), and thus I try to select all the other columns. E.g., newdata <- olddata[,2:10] is there a default symbol for the last column so I don't have to count all the columns? I tried newdata <- olddata[,2:] but it didn't work. I think it's better to focus on wanting to get rid of one column of data and not wanting to select every other column. You can do this as @Arun suggested: olddata[,-1] Or: olddata$ColNameToDelete <- NULL You can get the last column with ncol() : newdata <- olddata[,2:ncol

Java sort based on two columns

爱⌒轻易说出口 提交于 2019-12-04 00:42:29
问题 Lets say I have table like this: String | Int1 | Int2 "foo" 5 0 "faa" 4 1 "zaa" 0 1 "zoo" 4 2 "laa" 4 3 "loo" 1 4 What I would like to get is table like this: String | Int1 | Int2 "foo" 5 0 "laa" 4 3 "zoo" 4 2 "faa" 4 1 "loo" 1 4 "zaa" 0 1 First thing that happens is sort based on column Int1 . Second thing that happens is sort of based on column Int2 but only on rows that have same numbers in column Int1 How should I approach this problem without using any database engine? 回答1: You'd

Bash turning single comma-separated column into multi-line string

Deadly 提交于 2019-12-03 21:12:32
In my input file, columns are tab-separated, and the values inside each column are comma-separated. I want to print the first column with each comma separated value from the second. Mary,Tom,David cat,dog Kevin bird,rabbit John cat,bird ... for each record in the second column ( eg cat,dog ) i want to split record into array of [ cat, dog ] and cross print this against the first column. giving output ( just for this line ) Mary,Tom,David cat Mary,Tom,David dog output for whole file should be be: Mary,Tom,David cat Mary,Tom,David dog Kevin bird Kevin rabbit John cat John bird ... any suggest if

Create multiple columns in Pandas Dataframe from one function

这一生的挚爱 提交于 2019-12-03 17:31:09
问题 I'm a python newbie, so I hope my two questions are clear and complete. I posted the actual code and a test data set in csv format below. I've been able to construct the following code (mostly with the help from the StackOverflow contributors) to calculate the Implied Volatility of an option contract using Newton-Raphson method. The process calculates Vega when determining the Implied Volatility. Although I'm able to create a new DataFrame column for Implied Volatility using the Pandas

Pandas add new columns based on splitting another column

跟風遠走 提交于 2019-12-03 15:34:55
I have a pandas dataframe like the following: A B US,65,AMAZON 2016 US,65,EBAY 2016 My goal is to get to look like this: A B country code com US.65.AMAZON 2016 US 65 AMAZON US.65.AMAZON 2016 US 65 EBAY I know this question has been asked before here and here but none of them works for me. I have tried: df['country','code','com'] = df.Field.str.split('.') and df2 = pd.DataFrame(df.Field.str.split('.').tolist(),columns = ['country','code','com','A','B']) Am I missing something? Any help is much appreciated. You can use split with parameter expand=True and add one [] to left side: df[['country',

HTML Table - Both fixed and multiple variable column widths

房东的猫 提交于 2019-12-03 10:14:39
I have to build a table with 5 columns. The table width is variable (50% of content width). Some columns contain fixed-size buttons, so those columns should have a fixed with, say 100px. Some columns have text in them, so I want those columns to have variable column widths. For example: Column1: 20% of (tablewidth - sum(fixedwidth_columns))' Column2: 100px Column3: 40% of (tablewidth - sum(fixedwidth_columns)) Column4: 200px Column5: 40% of (tablewidth - sum(fixedwidth_columns)) What is the best way to achieve this? You could set the table-layout: fixed for the table element, then simply set

How to convert multiple columns to individual rows in R

狂风中的少年 提交于 2019-12-03 08:58:37
I have a data frame in R that has many rows (over 3000) with F0 (fundamental frequency) tracks of an utterance in it. The rows have the following information in them: speaker ID, group #, repetition #, accent type, sex, and then 50 columns of F0 points. The data looks like this: Speaker Sex Group Repetition Accent Word 1 2 3 4 105 M 1 1 N AILMENT 102.31030 102.31030 102.31030 102.31127 105 M 1 1 N COLLEGE 111.80641 111.80313 111.68612 111.36020 105 M 1 1 N FATHER 124.06655 124.06655 124.06655 124.06655 But instead of only going to X4, it has 50 points per row, so I have a 3562x56 data frame. I

How to create a 3-column responsive layout?

亡梦爱人 提交于 2019-12-03 06:04:22
问题 I have a 3 column layout. When access it from desktop, it shows like this: ------------------------------------------- | columnleft | columncenter | columnright | ------------------------------------------- I want it to be like this when view it from mobile / tablet / resize browser: ---------------- | columnleft | ---------------- | columncenter | ---------------- | columnright | ---------------- My sample below, and here is the JSFiddle. <style> .column-left{ float: left; width: 33%; }

Re-arrange multiple columns in a data set into one column using R

人盡茶涼 提交于 2019-12-03 02:48:42
I would like to combine three columns in one of my data sets into one with variable name "al_anim" and remove any duplicates, rank the values (animal ids) from lowest to highest, and re-number each animal from 1 to N under the variable name "new_id". anim1 <- c(1456,2569,5489,1456,4587) anim2 <- c(6531,6987,6987,15487,6531) anim3 <- c(4587,6548,7894,3215,8542) mydf <- data.frame(anim1,anim2,anim3) Any help would be very much appreciated! Baz Using mydf from your example: mydf <- data.frame(anim1, anim2, anim3) Stack the data: sdf <- stack(mydf) Then compute the unique elements using unique()