Hope everyone is doing well. I am using pandas and numpy and I would like to extract column values based on the first 3 letters (ap.) from a Dataframe. Below is an example of my Dataframe.
Name | Number |
---|---|
Orange | 2 |
APple | 6 |
Ap.ricot | 1 |
AP.19 | 1 |
Juap.rte | 3 |
I've tried df[df['Name'].str.lower().str.contains('ap.', na=False)].Name.unique() but it does not fully do the trick.
Output:
['AP.19','Ap.ricot']
The output should ideally be a list that I can then save onto a variable. Additionally, the 3 letters need to be at the start and in this order.
I am very new to Python so please explain as clearly as possible. Thank you.