I have a dictionary of 12 dfs named f and each df have the same columns: BacksGas_Flow_sccm, ContextID, StepID,Time_Elapsed, iso_forest, alarm.
What I am trying to do is to count the number of unique values in the BacksGas_Flow_sccm column and if the number id unique value is less than 10, I want to delete that df from the dictionary.
I tried doing something like this:
v = list(f.values())
for i in range (0, len(v)):
if (v[i]['BacksGas_Flow_sccm'].nunique()) < 10:
del (v[i])
but I get the following error:
Traceback (most recent call last):
File "<ipython-input-8-580f2e039fa5>", line 2, in <module>
if (v[i]['BacksGas_Flow_sccm'].nunique()) < 10:
IndexError: list index out of range
Any suggestions as to how can I do this?
P.S:
The number of unique values in the BacksGas_Flow_sccm of all the dfs
df unique values
1 2
2 5
3 373
4 2
5 4
6 3
7 4
8 560
9 141
10 4
11 5
12 4
I want to drop all the dfs in the dictionary except the 3rd, 8th and 9th.
I know it is not a good thing to share screenshots of the dfs, but since there are multiple dfs, it is difficult to post a sample df here. but this is how my dictionary of dfs look
