0

I would like to turn a Series of frequencies that I initialised in a loop over csv-files like so

setfreq_df = pd.concat([setfreq_df, EIS_csv['SetFreq'].astype(float)], ignore_index = True)

into a single boolean value or a boolean list. I need to check whether the data is corrupted, right now specifically whether all the frequencies are below 7000. I tried this in the following way:

bool_list = [(y < 7000) for y in setfreq_df]

which produces the output

[True]

I don't know how to interpret this result as I was expecting a list as long as the column of the DataFrame. Also I tried this with 6000 and it returned the same result even though I know there are frequencies of 6,5 kHz in the csv.

What went wrong here and how could I get it done? Thank you

lpnorm
  • 459
  • 3
  • 10
  • Use `setfreq_df[setfreq_df < 7000]` – jezrael Feb 03 '21 at 11:36
  • @jezrael This is not an answer to my question. How about you read it before you close it down. Your answer selects all rows that are below 7kHz. I don't want to select a row from the original frame. I want a boolean list or series of bools. – lpnorm Feb 03 '21 at 11:48
  • Ok, so need `setfreq_df < 7000` ? – jezrael Feb 03 '21 at 11:51
  • Ok that is wierd but yes exactly what I wanted, thank you. Can you reference me to a post where that syntax is explained? – lpnorm Feb 03 '21 at 11:58
  • hmm, I think here [`boolean indexing`](http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#boolean-indexing) – jezrael Feb 03 '21 at 11:59
  • compare column by some value, it is used mainly for filtering in boolean indexing. But is possible mask use like `setfreq_df < 7000` – jezrael Feb 03 '21 at 12:01
  • That is about selecting rows via boolean conditions. That is not what I meant which is why I did not think the post was a duplicate. With your second answer you are creating a new df, not just selecting rows. Does this work for functions in general? like for a function g: df_2 = g(df_1) This is the syntax I meant. – lpnorm Feb 03 '21 at 12:15
  • Sorry, not understand. So need answer `setfreq_df < 7000` or dupe for `setfreq_df < 7000` ? – jezrael Feb 03 '21 at 12:26
  • Does ```new_df = g(setfreq_df)``` work for general functions g() or only for boolean conditions (like ```g(x) : return (x < 7000)```)? – lpnorm Feb 03 '21 at 12:59
  • It is call for data of all column, so working like `mask = setfreq_df < 7000` (if understand well) – jezrael Feb 03 '21 at 13:03

0 Answers0