0

I have attached two dataframes and a sample of their data in the screenshot below.

In dataframe B, for each equipment ID, we will look into dataframe A using the columns 'CONSTRUCTION_TYPE', 'CONSTRUCTOR', and 'CONSTRUCTION_TYPE_FAMILY'.

If the conditions match, it will extract two values: the number of steps for refurbishment and the number of steps for preventive maintenance. However, I am facing a challenge in writing the conditions because the 'CONSTRUCTION_TYPE_FAMILY' column has multiple conditions.

Dataframe A enter image description here

Dataframe B enter image description here

Sample data for construction type family column

"""RFR 4"" OR ""RR 2"""

""" RFR 6"" OR ""RR 10"""

"RFR 4"

'"M" OR "T" OR "V"

"F" OR "H3xx" OR "300 A" OR "RCM " OR "RBF" OR "UCB"

NOT: RFR 4, RR 2, RFR 6, RR 10, R, C, D, M,T, V, VRC,VM, V, F, H3xx, 300 A, RCM, RBF, UCB, A vide

Sample data for Construction type column

Not "TFO-Reg (tri) RFR 4 New upgrade 2016 {???A}"

Not "TFO-Reg (tri) RFR 6 New upgrade 2016 {800A} "

TFO-Reg (tri) RFR 4 New upgrade 2016 {???A}

TFO-Reg (tri) RFR 6 New upgrade 2016 {800A}

Taylor
  • 113
  • 1
  • 1
  • 9
  • What do you mean by "'CONSTRUCTION_TYPE_FAMILY' column has multiple conditions."? – Amri Rasyidi Mar 23 '23 at 07:28
  • @AmriRasyidi he/she means the contstructor_type_family has "RFR4 or RR2" in df A. but in df B he has one value RFR 4. So instead of equality join it will be partial join based on text match. or you can pivot down table A and join with table B under equality conditions – Equinox Mar 23 '23 at 07:30
  • Also Can you paste the first few rows of data in the question itself ? – Equinox Mar 23 '23 at 07:31
  • In that case, maybe this [SO question](https://stackoverflow.com/questions/50983398/pandas-join-on-partial-string-match-like-excel-vlookup) can help – Amri Rasyidi Mar 23 '23 at 07:38
  • @Equinox I added the first few rows of data construction type family & Construction type – Taylor Mar 23 '23 at 09:02

0 Answers0