Questions tagged [pandas-merge]

Use this tag for questions related to the Pandas merge function or merge method of a Pandas DataFrame object

merge is a function (or method) used to merge DataFrame or named Series objects with a database-style join.

The join is done on columns or indexes. If joining columns on columns, the DataFrame indexes will be ignored. Otherwise if joining indexes on indexes or indexes on a column or columns, the index will be passed on.

See:

41 questions
0
votes
1 answer

Identify columns which cause non match between two dataframes

I compare two DataFrames (df1 and df2) each of which shall have unique rows for a given combination of keys. That means there are not duplicates for keys such as Col1 and Col2. import pandas as pd # OK NOK NOK df1 =…
0
votes
1 answer

How merge or join data in a Pandas nested DataFrame

I'm trying to figure out how to perform a Merge or Join on a nested field in a DataFrame. Below is some example data: df_all_groups = pd.read_json(""" [ { "object": "group", "id": "group-one", "collections": [ …
M1kep
  • 33
  • 6
0
votes
1 answer

Update values in a DataFrame by values in another by date

I tried to make a code to inputting version of items. There are two dataframes, one with the items, one with the version info. Here's a dummy data and a code I made: import pandas as pd from datetime import datetime Item =…
Jeong In Kim
  • 373
  • 2
  • 12
0
votes
1 answer

AssertionError when use df.loc in python

I created a script to load data, check NA values, and fill all NA values. Here is my code: import pandas as pd def filter_df(merged_df, var_list): ind = merged_df.Name.isin(var_list) return merged_df[ind] def pivot_df(df): return…
Carlos
  • 167
  • 1
  • 2
  • 14
0
votes
0 answers

Find nearest value for two columns from different dataframe in python

I have two DataFrames as shown below: data1 = {'Score1': [40,30,20], 'P1':[15.2, 13.3, 11.1], 'C1': [98,90,87]} df1 = pd.DataFrame(data1) df1 data2 = {'Score2': [35,33,26, 24], 'P2':[16.2, 14.7, 12.6, 11.4], 'C2': [98, 94, 86, 84]} df2 =…
user16151841
0
votes
1 answer

Mapping positions to names based on date in a pandas DataFrame

I have a DataFrame of "positions" and the "date they came to office": position cameToOfficeDate CEO 2020-06-01 CEO 2021-01-01 CEO 2021-02-02 Slave 2020-01-01 I want to map the position to employee's names for different…
TYL
  • 1,577
  • 20
  • 33
0
votes
1 answer

Appending column values from one dataframe to another as a list

I have dozens of very similar dataFrames. What I want is to combine all 'VALUE' column values from each into lists, and return a dataFrame where the 'VALUE' column is comprised of these lists. I only want to do this for rows where 'PV' contains a…
0
votes
2 answers

Merge a Dataframe and a Series with the same index

I got a Dataframe as below: Name Sales Datetime 2021-06-01 Amy 1000 2021-06-02 Amy 1500 2021-06-03 Amy 2300 2021-06-01 Joyce 3200 2021-06-02 Joyce 1422 2021-06-03 Joyce 1002 And I got another Series as…
Hang
  • 197
  • 1
  • 11
0
votes
1 answer

Merge two dataframes by different indexes

I am trying to merge two dataframes based on the Date column but in df1 the data column is titled Index while the other is called…
heff
  • 41
  • 5
0
votes
2 answers

Iterate through several lists and get a new list as a result

I have two DataFrames that look like this: dfH TICKER Qty PPC Date PxQ PPerc 0 C 6 4185.0 2021-11-13 25110.0 0.097416 1 AAPL 20 3058.0 2021-11-13 61160.0 0.237274 2 JPM 3 5915.0 2021-11-13 17745.0 …
Billy101
  • 19
  • 2
-1
votes
2 answers
1 2
3