Top "Data-manipulation" questions

Data manipulation is the process of altering data from a less useful state to a more useful state.

pandas reset_index after groupby.value_counts()

I am trying to groupby a column and compute value counts on another column. import pandas as pd dftest = pd.…

python pandas dataframe data-manipulation data-science
Arranging rows in custom order using dplyr

With arrange function in dplyr, we can arrange row in ascending or descending order. Wonder how to arrange rows in …

r dplyr data-manipulation
Windows command for cutting columns from a text

The following content is stored in a file: chrome.exe 512 Console 0 73,780 K chrome.exe 800 Console 0 11,052 K chrome.exe 1488 Console 0 92,720 K …

windows command-line data-manipulation cut
How to run tapply() on multiple columns of data frame using R?

I have a data frame like the following: a b1 b2 b3 b4 b5 b6 b7 b8 b9 D 4 6 9 5 3 9 7 9 8 F 7 3 8 1 3 1 4 4 3 …

r data-manipulation
Extract letters from a string in R

I have a character vector containing variable names such as x <- c("AB.38.2", "GF.40.4", "ABC.34.2"). I want to …

r string data-manipulation
get first and last values in group – dplyr group_by with last() and first()

The code below should group the data by year and then create two new columns with the first and last …

r dplyr data-manipulation
Assign value to group based on condition in column

I have a data frame that looks like the following: > df = data.frame(group = c(1,1,1,2,2,2,3,3,3), date = c(1,2,3,4,5,6,7,8,9), value = c(3,4,3,4,5,6,6,4,9)) &…

r data-manipulation
Extract non null elements from a list in R

I have a list like this: x = list(a = 1:4, b = 3:10, c = NULL) x #$a #[1] 1 2 3 4 # #$b #[1] 3 4 5 6 7 8 9 10 # #$c #NULL and I want …

r data-manipulation
How to remove groups of observation with dplyr::filter()

For the following data ds <- read.table(header = TRUE, text =" id year attend 1 2007 1 1 2008 1 1 2009 1 1 2010 1 1 2011 1 8 2007 3 8 2008 NA 8 2009 3 8 2010 NA 8 2011 3 9 2007 2 9 2008 3 9 2009 3 9 2010 5 9 2011 5 10 2007 4 10 2008 4 10 2009 2 10 2010 NA 10 2011 NA ") ds&…

r data-manipulation dplyr subset
Converting all occurrence of True/False to 1/0 in a dataframe with mixed datatype

I have a dataframe that has about 100 columns, There are some Boolean columns and some chars. I want to replace …

python data-manipulation