Reputation: 687
I want to write a numpy funcction that filters the a
array to only the ones that end with USD
and USDC
. The function below only works with one filter but does not work with two filters 'USD', 'USDC'
. Code has been gotten from issue:issue
import numpy as np
a = np.array(['BTCUSD', 'ETHUSD', 'David', 'georGe', 'XRPUSD', 'USDAUD', 'ETHUSDC'])
print(a[np.char.endswith(a, 'USD', 'USDC')])
Upvotes: 0
Views: 24
Reputation: 3346
try this:
import numpy as np
a = np.array(['BTCUSD', 'ETHUSD', 'David', 'georGe', 'XRPUSD', 'USDAUD', 'ETHUSDC'])
b = np.array([i for i in a if i.endswith('USDC') or i.endswith('USD')])
print(b)
Upvotes: 1