I'm trying to create an empty data frame with pandas that has two columns (['originating_number','terminating_number']. After I create this new empty data frame, my goal is to loop through another data frame I have an add a row to this new empty data frame if certain criteria is met. Unfortunately, I'm running into a snag with either initializing empty data frame or adding to it. Here is my current code (where records represents my other data frame that I'm working with):
verified_frame = pd.DataFrame(columns=['originating_number_2', 'terminating_number_2'])
for index, row in records.iterrows():
originating_number_length = len(str(row['originating_number']))
terminating_number_length = len(str(row['terminating_number']))
if originating_number_length == 10 and terminating_number_length == 10:
temp_df = pd.DataFrame([row['originating_number'],row['terminating_number']])
verified_frame.append(temp_df)
However, when I set a trace after this code (within the if block), I can see that my temp_df has the right values, but when I look at the verified_frame, the values have not been added.
Thanks for the help!