Fix Python – filter items in a python dictionary where keys contain a specific string

I’m a C coder developing something in python. I know how to do the following in C (and hence in C-like logic applied to python), but I’m wondering what the ‘Python’ way of doing it is.
I have a dictionary d, and I’d like to operate on a subset of the items, only those who’s key (string) contains a specific substring.
i.e. the C logic would be:
for….

Fix Python – Logical operators for Boolean indexing in Pandas

I’m working with a Boolean index in Pandas.
The question is why the statement:
a[(a[‘some_column’]==some_number) & (a[‘some_other_column’]==some_other_number)]

works fine whereas
a[(a[‘some_column’]==some_number) and (a[‘some_other_column’]==some_other_number)]

exits with error?
Example:
a = pd.DataFrame({‘x’:[1,1],’y’:[10,20]})

In: a[(a[‘x’]==….

Fix Python – Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

I want to filter my dataframe with an or condition to keep rows with a particular column’s values that are outside the range [-0.25, 0.25]. I tried:
df = df[(df[‘col’] < -0.25) or (df['col'] > 0.25)]

But I get the error:

Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

….