I am trying to create a pandas DataFrame "B" taking into account a row by row reading of another DataFrame "A".
The thing is that I want to fill the cell's values of the new DataFrame"B" counting specific cases that ocurr in the first data set "A".
I cant initializes the DataFrame "B" with all zeros, because I dont know how many rows it will have.
If I dont initializes the cell's values of the DataFrame "B" I get this error
KeyError: "the label ['0'] is not in the [index]"
when I try:
for i in range(len(df_A.index)):
if (int(df_A.iloc[i][3])) == sec_types_crmc[3]:
df_B.at["'"+str(i)+"'", 'bin_0'] = df_B.loc["'"+str(i)+"'"]['bin_0'] + 1