Python Forum
Partial Matching Rows In Pandas DataFrame Query
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Partial Matching Rows In Pandas DataFrame Query
#2
I have modified that part of the Code, to the following :-

remove=[]
for i,row1 in final_df_.iterrows():
    loc = row1[0] and row1[0][:4]
   #loc = row1[0] and row1[0][-4:]
    date = row1[1]
    for j,row2 in final_df.iterrows():
         if loc in row2[0] and date==row2[1] or loc in row2[0][:4] and date==row2[1]:
        #if loc in row2[0] and date==row2[1] or loc in row2[0][-4:] and date==row2[1]:   
            remove.append(i)
            
final_df_=final_df_.drop(final_df_.index[remove])
final_df_.reset_index(drop=True,inplace=True)
full_df=pd.concat([final_df,final_df_],axis=0)
This matches the first word in rows in the other DataFrame, where the first 4 letters are the same.

The hashed out lines of code, does the same, but for the last 4 letters of the first word in rows.

Anyone any ideas, how to ignore the comma, at the end of the first word in the rows ?

Regards

Eddie Winch
Reply


Messages In This Thread
RE: Partial Matching Rows In Pandas DataFrame Query - by eddywinch82 - Jul-08-2021, 06:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  partial functions before knowing the values mikisDeWitte 4 603 Dec-24-2023, 10:00 AM
Last Post: perfringo
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 740 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  How is pandas modifying all rows in an assignment - python-newbie question markm74 1 703 Nov-28-2023, 10:36 PM
Last Post: deanhystad
  Move Files based on partial Match mohamedsalih12 2 822 Sep-20-2023, 07:38 PM
Last Post: snippsat
  Question on pandas.dataframe merging two colums shomikc 4 836 Jun-29-2023, 11:30 AM
Last Post: snippsat
  Partial KEY search in dict klatlap 6 1,271 Mar-28-2023, 07:24 AM
Last Post: buran
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 5,663 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,483 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  help how to get size of pandas dataframe into MB\GB mg24 1 2,380 Jan-28-2023, 01:23 PM
Last Post: snippsat
  pandas dataframe into csv .... exponent issue mg24 10 1,796 Jan-20-2023, 08:15 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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