multiple-columns

Split a text(with names and values) column into multiple columns in Pandas DataFrame

…衆ロ難τιáo~ 提交于 2021-01-27 23:16:32
问题 I have problem with speed of my algorithm, is too slow. I have a big dataframe and wanna create columns depends on the name and value in other. I am looking for a solution maybe in Pandas. Before running I don't know the size of the future columns. Here is a simple schema. "column"<==>"value"<br>"column"<==> "value"<br>... my data frame id | params | ---|----------------- 0 |currency<=>PLN<br>price<=>72.14<br>city<==>Berlin ---|----------------- 1 |price<=>90<br>area<=>72.14<br>city<==>San

Replacing more than n consecutive values in Pandas DataFrame column

空扰寡人 提交于 2021-01-27 12:48:16
问题 Supposing I have the following DataFrame df df = pd.DataFrame({"a" : [1,2,2,2,2,2,2,2,2,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5], "b" : [3,3,3,3,3,3,3,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,7,7], "c" : [4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,1,2,2,2,2,2,2,2,2,3,3]}) And I wish to replace number 4's which repeat more than 10 times in a row, in any column (there could be hundreds of columns), with 10 4's and the remainder 5's. So for example, 12 consecutive 4's would be replaced

get column value based on another column with list of strings in pandas dataframe

无人久伴 提交于 2021-01-27 11:58:45
问题 I tried the link. But it doesnt work for my example given below. I tried the loc[0] for the output. I tried .item(). But none of these help me. >>> df2 = pd.DataFrame({ 'Item':['[Phone]', '[Watch]', '[Pen]', '[Pencil]', '[Knife]'], 'RelatedItem': ['[Phone cover]', '[Watch strap]', '[Pen cap]', '[Pencil lead]', '[fork]'], 'CountinInventory':['20','50','40','80','90']}) >>> df2 Item RelatedItem CountinInventory 0 [Phone] [Phone cover] 20 1 [Watch] [Watch strap] 50 2 [Pen] [Pen cap] 40 3 [Pencil

get column value based on another column with list of strings in pandas dataframe

爱⌒轻易说出口 提交于 2021-01-27 11:57:29
问题 I tried the link. But it doesnt work for my example given below. I tried the loc[0] for the output. I tried .item(). But none of these help me. >>> df2 = pd.DataFrame({ 'Item':['[Phone]', '[Watch]', '[Pen]', '[Pencil]', '[Knife]'], 'RelatedItem': ['[Phone cover]', '[Watch strap]', '[Pen cap]', '[Pencil lead]', '[fork]'], 'CountinInventory':['20','50','40','80','90']}) >>> df2 Item RelatedItem CountinInventory 0 [Phone] [Phone cover] 20 1 [Watch] [Watch strap] 50 2 [Pen] [Pen cap] 40 3 [Pencil

Excel - SUMIFS for multiple columns

房东的猫 提交于 2021-01-24 08:27:08
问题 I need to sum the values of several columns, if other cells in the same row match a predefined criteria. The working formula for only 3 columns is the following: =SUM(SUMIFS(‘Sheet1'!W:W; ‘Sheet1'!$B:$B;"Sales";‘Sheet1'!$C:$C;">=4");SUMIFS(‘Sheet1'!X:X; ‘Sheet1'!$B:$B;"Sales";‘Sheet1'!$C:$C;">=4");SUMIFS(‘Sheet1'!Y:Y; ‘Sheet1'!$B:$B;"Sales";‘Sheet1'!$C:$C;">=4")) I will need to use the formula for several cells (and sum more than 10 columns per time) and I will need to change the columns

Split a list column into multiple columns in R

落爺英雄遲暮 提交于 2021-01-21 12:25:10
问题 I have a data table where the last column is a column of lists. Below is how it looks: Col1 | Col2 | ListCol -------------------------- na | na | [obj1, obj2] na | na | [obj1, obj2] na | na | [obj1, obj2] What I want is Col1 | Col2 | Col3 | Col4 -------------------------- na | na | obj1 | obj2 na | na | obj1 | obj2 na | na | obj1 | obj2 I know that all the lists have the same amount of elements. Edit: Every element in ListCol is a list with two elements. 回答1: Here is one approach, using

Split a list column into multiple columns in R

…衆ロ難τιáo~ 提交于 2021-01-21 12:23:26
问题 I have a data table where the last column is a column of lists. Below is how it looks: Col1 | Col2 | ListCol -------------------------- na | na | [obj1, obj2] na | na | [obj1, obj2] na | na | [obj1, obj2] What I want is Col1 | Col2 | Col3 | Col4 -------------------------- na | na | obj1 | obj2 na | na | obj1 | obj2 na | na | obj1 | obj2 I know that all the lists have the same amount of elements. Edit: Every element in ListCol is a list with two elements. 回答1: Here is one approach, using

How to edit 'column select' shortcut in Sublime text 3 portable

空扰寡人 提交于 2021-01-04 08:51:00
问题 I am a novice to Sublime text. Previously I used notepad++. I use column selection frequently. In notepad++ it comes to me handy with alt + left mouse click which I can drag up to my wished selection. In Sublime text, it is shift + right mouse click and drag up to wished selection for Windows. I want to change it to alt + left mouse click as I have used it in notepad++. I tried searching in preferences > key bindings in sublime text. But couldn't find mouse-key mappings there. I am using

How to edit 'column select' shortcut in Sublime text 3 portable

自作多情 提交于 2021-01-04 08:50:10
问题 I am a novice to Sublime text. Previously I used notepad++. I use column selection frequently. In notepad++ it comes to me handy with alt + left mouse click which I can drag up to my wished selection. In Sublime text, it is shift + right mouse click and drag up to wished selection for Windows. I want to change it to alt + left mouse click as I have used it in notepad++. I tried searching in preferences > key bindings in sublime text. But couldn't find mouse-key mappings there. I am using

Testing for multiple identical columns in R

若如初见. 提交于 2020-12-30 17:35:55
问题 Is there a short way to test for identity over multiple columns? For example, over this input data=data.table(one=c(1,2,3,4), two=c(7,8,9,10), three=c(1,2,3,4), four=c(1,2,3,4) ) Is there something that would return all the columns that are identical to data$one? Something like allcolumnsidentity(data$one, data) # compares all columns with respect to data$one Should return (TRUE, FALSE, TRUE, TRUE) since data$three and data$four are identical to data$one. I saw the identical() and comapre()