2

Hi anyone can help on this? i got error when i run this:

conditions5 = [
    (data1['Payment Mode'] == '03')
]

choices5 = data1['Value Date']

data1['Valid From Date'] = np.select(conditions5, choices5, default ='') 
data1

Error: List of cases must be same length as list of conditions

I already tried using loc but the same error happen. How can i fix this?

data1.loc[data1['Payment Mode'] == '03'] = data1['Value Date']

Error: Must have equal len keys and value when setting with an iterable

Nick ODell
  • 15,465
  • 3
  • 32
  • 66
Amy Diana
  • 129
  • 1
  • 5

2 Answers2

0

Try np.where:

data1['valid from date'] = np.where(conditions5, data1['Value Date'], '')
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
0

Try this:

data1['Valid From Date'] = np.where(data1['Payment Mode'] == '03', data1['Value Date'], '')
Kay
  • 2,057
  • 3
  • 20
  • 29