0

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')])

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.