fellow Pytoneers or Pythonistas,
I am hoping I can get your help on this issue:
I have more than one pandas data frames that contain as in the example below:
I would like to create a function that will count values from a list e.g. [a,b,c] and iterate through the columns and the data frames. I would like to return the total number of items found in the columns from the list. I wrote this code, but it doesn't seem to do the trick. Could you please help? Thank you in advance for your answers. PS: As I am new to this, my karma is quite low :D
list_of_dataframes = [k,p,r]
list_of_chars = ["a","b","c"]
for dataframe in list_of_dataframes:
for values in list_of_chars:
for columns in dataframe:
count = 0
if dataframe.columns.str.contains(list_of_chars):
dataframe['Total']=count+1
else dataframe['Total']
