0

I am curious, let's say. I have dataframes (for instances: a1, b1, c1, a2, b2, c2, a3, b3, c3). I want to extract dataframes that contain specific text 'a' and put them into a container of list.

As = [a1,a2,a3]

is it possible? any reference links ?

Many thanks.

stvlam22
  • 63
  • 7
  • It is impossible, object cannot be aware of their variable name. In fact, a python object can have zero or more than one name referring to it. If you want to be able to use names programmatically, store your objects in a dictionary: `dfs = {'a1': a1, 'b1': b1, ...}` then filter based on the string: `out = {k: v for k,v in dfs.items() if k.startswith('a')}` (or `if 'a' in k` if position doesn't matter). – mozway Jul 20 '23 at 14:26
  • okay thank u, mozway – stvlam22 Jul 20 '23 at 14:29

0 Answers0