multiple-columns

Convert datetime string to new columns of Day, Month, Year in pandas data frame

霸气de小男生 提交于 2019-12-05 16:15:28
I am new to python and have a pretty simple (hopefully straightforward!) question. Say that I have a data frame with 3 columns: time (which is in the format YYYY-MM-DDTHH:MM:SSZ), device_id, and rain but I need the first column, "time", to become three columns of "day", "month", and "year" with values from the timestamp. So the original data frame looks something like this: time device_id rain 2016-12-27T00:00:00Z 9b839362-b06d-4217-96f5-f261c1ada8d6 NaN 2016-12-28T00:00:00Z 9b839362-b06d-4217-96f5-f261c1ada8d6 0.2 2016-12-29T00:00:00Z 9b839362-b06d-4217-96f5-f261c1ada8d6 NaN 2016-12-30T00:00

CSS3 columns cutting off <li>s

徘徊边缘 提交于 2019-12-05 15:40:48
I am trying to use css3 columns with a list ( <li> ). I am having trouble making it work. I defined a div that wraps the <ul> div.ul-container { -moz-column-width: 310px; -moz-column-gap: 10px; -webkit-column-width: 310px; -webkit-column-gap: 10px; column-width: 310px; column-gap: 10px; } This works fine when I have three <li> s or above. But when I have less than that (2 or 1) it seems to cut off the <li> . I tried defining a min-height which didn't work as well (it treated it as height). screenshot: any ideas? Lucía Amado This thread is a bit old, but I had the same issue recently and used

Gathering specific pairs of columns into rows by dplyr in R [duplicate]

孤人 提交于 2019-12-05 10:46:25
This question already has an answer here: Reshaping multiple sets of measurement columns (wide format) into single columns (long format) 7 answers I am trying to convert a data frame from wide to long format by gathering specific pairs of columns of which example is shown below: An example of data frame df <- data.frame(id=c(1,2,3,4,5), var=c("a","d","g","f","i"),a1=c(3,5,1,2,2), b1=c(2,4,1,2,3), a2=c(8,1,2,5,1), b2=c(1,6,4,7,2), a3=c(7,7,2,3,1), b3=c(1,1,4,9,6)) Initial table: id var a1 b1 a2 b2 a3 b3 1 1 a 3 2 8 1 7 1 2 2 d 5 4 1 6 7 1 3 3 g 1 1 2 4 2 4 4 4 f 2 2 5 7 3 9 5 5 i 2 3 1 2 1 6

Windows 8 XAML multi-column text

独自空忆成欢 提交于 2019-12-05 10:34:34
Is there a way to make columns in a text? I have one big string with the text i have to display, and i have a fixed height of the textblock, and have to make the text display in column. like this image: Thanks! Have you looked in the "common" folder of the default solution templates? IIRC there is a control named something like ColumnTextBlock (or something similar) in there that does this for you. If it isn't in the default template you use, try creating a new grid application and look in there - it gets used in the item detail XAML page. HTH The component is called RichTextColumns which

R - Combining multiple columns together within a data frame, while keeping connected data

给你一囗甜甜゛ 提交于 2019-12-05 07:34:25
问题 So I've looked quite a lot for an answer to this question, but I can't find an answer that satisfies my needs or my understanding of R. First, here's some code to just give you an idea of what my data set looks like df <- data.frame("Year" = 1991:2000, "Subdiv" = 24:28, H1 = c(31.2,34,70.2,19.8,433.7,126.34,178.39,30.4,56.9,818.3), H2 = c(53.9,121.5,16.9,11.9,114.6,129.9,221.1,433.4,319.2,52.6)) > df Year Subdiv H1 H2 1 1991 24 31.20 53.9 2 1992 25 34.00 121.5 3 1993 26 70.20 16.9 4 1994 27

how to stop inline-block whitespace being rendered in the browser

℡╲_俬逩灬. 提交于 2019-12-05 05:53:16
Roughly speaking, attempting to build a four-column layout, I've got this HTML: <div> <div>A column</div> <div>A column</div> <div>A column</div> <div>A column</div> </div> And I've got this CSS: div { background: #ccc; } div div { background: #eee; display: inline-block; width: 25%; } -> Fiddle me this <- When rendered in the browser (Currently, I have been testing with Chrome only) the whitespace between the nested div elements (in this example the whitespace is caused by line breaks) is rendered, thus throwing my layout out. Clearly, I can float my nested divs... div { background: #ccc; }

How to Rename Multiple Columns on a Reset Index with Pandas

青春壹個敷衍的年華 提交于 2019-12-05 05:01:56
I'm trying to figure out if there is a way to rename Pandas columns when you try to reset the index. I see in the documentation that you can use the "name" parameter to set the column name of a reset index if there is only one column, but I'm curious if there is a way to do this for multiple columns. For example: df1 = pd.DataFrame({ 'A' : ['a1', 'a1', 'a2', 'a3'], 'B' : ['b1', 'b2', 'b3', 'b4'], 'D1' : [1,0,0,0], 'D2' : [0,1,1,0], 'D3' : [0,0,1,1], }) df1.set_index(['B','A']).stack().reset_index() The result leaves you with: Out[82]: B A level_2 0 0 b1 a1 D1 1 1 b1 a1 D2 0 2 b1 a1 D3 0 3 b2

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

一世执手 提交于 2019-12-05 04:17:17
问题 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

CSS auto column-count when max-height is fixed

不想你离开。 提交于 2019-12-05 03:29:43
I wish to achieve a layout where an element (in my case a <ul> ) expands to 2 (or more) columns when the height reaches a certain limit. So for example, if the height is only enough for 3 items, and I have 5, the 4th and 5th item go to the second column, which is only created if needed. I tried to do this by setting the max-height as suggested here with column-count and column-width set to auto via the columns (I tried setting them separately too, same behaviour). If on the other hand I change the column-count to a fixed integer, it works and balances the items, but this is not dynamic as I

R: Replace multiple values in multiple columns of dataframes with NA

我只是一个虾纸丫 提交于 2019-12-04 23:40:39
I am trying to achieve something similar to this question but with multiple values that must be replaced by NA, and in large dataset. df <- data.frame(name = rep(letters[1:3], each = 3), foo=rep(1:9),var1 = rep(1:9), var2 = rep(3:5, each = 3)) which generates this dataframe: df name foo var1 var2 1 a 1 1 3 2 a 2 2 3 3 a 3 3 3 4 b 4 4 4 5 b 5 5 4 6 b 6 6 4 7 c 7 7 5 8 c 8 8 5 9 c 9 9 5 I would like to replace all occurrences of, say, 3 and 4 by NA, but only in the columns that start with "var". I know that I can use a combination of [] operators to achieve the result I want: df[,grep("^var[