Questions tagged [data-wrangling]
1242 questions
-2
votes
1 answer
Populate array of objects in Javascript using two different values as range
Having a an array of objects with the following structure:
[{value: "a", start: 1950, end: 1954, description: "aaa"},
{value: "b", start: 1953, end: 1956, description: "bbb"},
{value: "c", start: 1960, end: 1962, description: "ccc"}]
how can I…

console.log
- 177
- 2
- 16
-2
votes
2 answers
In R, looking to remove duplicates from certain rows, and combine rows on others
I have a dataframe that has 5 columns. I want to remove duplicates based on "OPP_ID" column but want to merge the records for the last two columns "Sales" and "Marketing". The last two columns have NAs as well. I've tried several approaches but I…

indy anahh
- 33
- 4
-2
votes
1 answer
Using "LETTERS" to add a row to dataset
I have a dataset that contains 301 columns. I want to add a row that contains a unique letter starting with a and repeats until the final column. What I have is:
DF:
Var1 Var2.....Var78 Var79...Var130V Var131
What I want in my extra row is:
…

JeffB
- 139
- 1
- 10
-2
votes
3 answers
Python Regex for pattern 2 digits to 2 digits like - 26 to 40
Please help, regex blown my mind.
I am cleaning data in Pandas dataframe (python 3).
I tried so many combos of regex found on the web for digits but none work for my case. I can't seem to figure out how to write my own regex for pattern 2 digits…

The smell of roses
- 117
- 1
- 2
- 10
-2
votes
1 answer
Scraping Wikipedia table in python : common grid style
I have seen that recently table for List of postal codes of Canada on Wikipedia has changed from normal table to common grid style List of postal codes of Canada: M.
I tried in different way but its not easy to convert it into df.
Problem with this…

Apurv
- 13
- 3
-2
votes
2 answers
How to map strings in a Pandas Series
Is there a way to map characters for a column in Pandas.
For example, I would like to map a column say info like this {"1": "US", "2":"DE", "3":"CA", "4":"AU", "5":"BE"}
So instead of the numbers, I would like something US and the rest to show
EDIT…

JA-pythonista
- 1,225
- 1
- 21
- 44
-3
votes
2 answers
starting my second data project and already ran into something I can't figure out
So I have a table with a column for active covid cases and another one for the city the cases are reported in. Now, I need to somehow sum all the cases for a given state on each day for each state. For example, I have 2 years of daily active covid…
-3
votes
2 answers
Changing Table structure in Pandas Python
I want to change the shape of the following table
to
using pandas dataframe. How can I do it?

user15631510
- 1
- 1
-3
votes
1 answer
R: Covernt a complex time series dataframe to long
This is for R
date <- seq(as.Date("2020/03/11"), as.Date("2020/03/16"), "day")
x_pos_a <- c(1, 5, 4, 9, 0)
x_pos_b <- c(2, 6, 9, 5, 4)
like so [...]
I have a timeseries dataframe with 69 time points. The rows in the dataframe are dates.
Four…

RTERG
- 1
- 2
-4
votes
1 answer
How to join two data frames without introducing NAs and duplicate columns?
My data frame has some missing values for certain variables. I have put together another data frame that has those missing values. When I try to combine them, it introduces NA values with duplicate columns. I have tried all four joins (left, right,…

Ahsk
- 241
- 1
- 7
-5
votes
1 answer
Updating string elements in a list in Python
I have a list of string elements where list = [X, Y, Z].
I want to update the elements in the list such that it becomes [X_AAA, X_BBB, X_CCC, Y_AAA, Y_BBB, Y_CCC, Z_AAA, Z_BBB, Z_CCC]. Essentially, I'm appending AAA, BBB and CCC to every element in…

jo_
- 677
- 2
- 11