Questions tagged [merging-data]
173 questions
224
votes
9 answers
Merging two arrays with the "+" (array union operator) How does it work?
I have some code that appears to merge the data from two arrays using +=, but it doesn't include all of the elements in the element. How does it work?
Example:
$test = array('hi');
$test += array('test', 'oh');
var_dump($test);
Output:
array(2) {
…

user198729
- 61,774
- 108
- 250
- 348
107
votes
11 answers
Merge two numerically-keyed associative arrays and preserve the original keys
I have two arrays like this:
array(
'11' => '11',
'22' => '22',
'33' => '33',
'44' => '44'
);
array(
'44' => '44',
'55' => '55',
'66' => '66',
'77' => '77'
);
I want to combine these two array such that it does not contains duplicate and as well…

Awan
- 18,096
- 36
- 89
- 131
16
votes
2 answers
array_replace() vs. union operator in PHP
In PHP, (given that $a, $b and $c are arrays) is $a = array_replace($b, $c) always functionally identical to $a = $c + $b?
I can't seem to find any edge cases that would indicate otherwise.
(just working with one dimension, this question isn't…

Dan Lugg
- 20,192
- 19
- 110
- 174
13
votes
6 answers
Performance with time related algorithm
I have a function that take 2 arrays ($schedule, $remove), both are arrays of days with time inside, it will remove time from the schedule .
Now this function is working fine if I have between 1 & 20 user it takes 2-4 seconds to generate the…

Tarek
- 3,810
- 3
- 36
- 62
12
votes
3 answers
AS3 Fastest way to merge multiple arrays
I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.
I've done this, but it seems like a really slow and ugly way of doing it:
var…

Marty
- 39,033
- 19
- 93
- 162
11
votes
7 answers
How to merge two databases in SQL Server?
Both databases have the same schema, but they may experience conflict with primary key in some tables. So I want them to just ignore the duplicate rows, and continue merging further.

Ish
- 28,486
- 11
- 60
- 77
9
votes
3 answers
Merge multiple associative arrays and add missing columns with a default value
I have the following code:
$a = array('a' => 'some value', 'b' => 'some value', 'c' => 'some value');
$b = array('a' => 'another value', 'd' => 'another value', 'e' => 'another value', 'f' => 'another value');
$c = array('b' => 'some more value',…

MrUpsidown
- 21,592
- 15
- 77
- 131
8
votes
2 answers
Merging two/three records in rails
I want to merge two profiles into one. What is the best way to do this in Rails.
I have two profiles say user1 and user2 and there are at least 30 tables associated with them.
Now i want to merge them together so that there should be one profile say…

Salil
- 46,566
- 21
- 122
- 156
7
votes
4 answers
Pandas: merge two dataframes ignoring NaN
Assume I have the following two DataFrames:
X Y Z
1 0.0 0.0 0.0
2 1.0 2.0 3.0
3 4.0 2.0 0.0
4 NaN NaN NaN
5 NaN NaN NaN
6 NaN NaN NaN
7 NaN NaN NaN
8 NaN NaN NaN
and
X.2 Y.2 Z.2
1 NaN NaN NaN
2 NaN NaN NaN
3 NaN NaN…

Hendrik Wiese
- 2,010
- 3
- 22
- 49
4
votes
2 answers
changing numeric data variable into date format in R to merge two datasets
I am trying to merge two datasets where date and an id variable are the two common identifiers.
In one dataset the date variable is of character type and looked like this: '31jan2013'. We thus used the as.Date function to change it into date format…

EIBC
- 43
- 2
4
votes
3 answers
Flip associative array and store new values in subarrays to prevent losing duplicated values
I have a flat associative array which may contain duplicate values.
Array (
[for-juniors] => product_category
[for-men] => product_category
[coats] => product_category
[for-women] => product_category
[7-diamonds] => brand
)
I…

Ahmed Fouad
- 2,963
- 10
- 30
- 54
3
votes
2 answers
Merging data frames without duplicating data when several matches are possible
I need merge two data frames, without having duplicate rows/duplicated data if there is more than one match. Basically, if the matching between my dataframes is ambiguous, I would like the ambiguous rows to NOT be matched, and each row to remain…

Myscellia
- 35
- 3
3
votes
2 answers
Merge associative row data in a 2d array based on a column value
I need to merge the row data of my 2d array where rows share the same messageID value.
$myarray = [
[
'messageId' => '5ACE9D8841',
'sender' => 'john@doe.com'
],
[
'messageId' => '7EE67D8170',
'sender' =>…

dubwise
- 33
- 3
3
votes
3 answers
Merging tables that are sorted differently with R
I have 2 big tables. One with identifiers (unsorted), another with a list of identifiers (containing all which are in the first table) plus the associated values for one variable.
I want to add a column to my first table containing the associated…

freya
- 31
- 2
3
votes
1 answer
Resampling and merging data frame with python
Hi I have created a dictionary of dataFrame with this code
import os
import pandas
import glob
path="G:\my_dir\*"
dataList={}
for files in glob.glob(path):
dataList[files]=(read_csv(files,sep=";",index_col='Date'))
The different dataframe…

Lorenzo Bottaccioli
- 441
- 1
- 7
- 20