Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas dataframe merge
#1
my two datasets are

patient_info:

patient_id	year_born	sex
a7G2n	  1985	       m
h9GH5	  1981	       f
b75GH	  1991	       f
AGK67	  1995	       f
gh8j9	  2000	       m
K78DA	  1600	       m
gh8j9	  2000	       m


patient_results:

id	   erythrocytes	ESR
a7G2n	      4.5	      7
h9GH5	      5.1	
b75GH	      5.3	      3
AGK67		    2
gh8j9	      6.1	     10
K78DA	      5.5	      7

my code is :
import pandas as pd
patient_info = pd.read_csv('patient_info.csv')
patient_results = pd.read_csv('patient_results.csv')
patient_info = patient_info.drop(5)
patient_info = patient_info.duplicated().values.any()
patient_results = patient_results.fillna(0.0)
all_patient_data =  patient_info.merge(patient_results, left_on='patient_id', right_on='id')

I then receive the following error

Error:

Traceback (most recent call last):
  File "run.py", line 139, in <module>
    exec(open(userscript_path).read())
  File "<string>", line 7, in <module>
AttributeError: 'numpy.bool_' object has no attribute 'merge'


I am fairly new to python and data frames.

Please advise on where the error may be?
Reply
#2
I believe that in line 30 you convert your dataframe into a boolean object. Would start there.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  HTML Decoder pandas dataframe column mbrown009 3 962 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 1,091 Jan-06-2023, 10:53 PM
Last Post: haihal
  Pandas Dataframe Filtering based on rows mvdlm 0 1,396 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 2,269 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,243 Jan-30-2022, 10:21 AM
Last Post: anto5
  PANDAS: DataFrame | Replace and others questions moduki1 2 1,759 Jan-10-2022, 07:19 PM
Last Post: moduki1
  PANDAS: DataFrame | Saving the wrong value moduki1 0 1,527 Jan-10-2022, 04:42 PM
Last Post: moduki1
  update values in one dataframe based on another dataframe - Pandas iliasb 2 9,103 Aug-14-2021, 12:38 PM
Last Post: jefsummers
  empty row in pandas dataframe rwahdan 3 2,421 Jun-22-2021, 07:57 PM
Last Post: snippsat
Question Pandas - Creating additional column in dataframe from another column Azureaus 2 2,919 Jan-11-2021, 09:53 PM
Last Post: Azureaus

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020