I am trying to append a dataframe csv_objects to another dataframe result, to get one combined dataframe. it has the exact same columns, its created in the same way, like this: Both dataframes where created like the code below, one gets saved to csv , then later read again and thats when i try to combine it with the newly created one.
result = pd.DataFrame(data=np.reshape(self.get_data_from_object(object_id), (1, 14)),
columns=("corners", "parts", "sharp", "steep",
"flat","flat_count", "over_air", "object_overhang", "bridges", "thin",
"total_area", "length_width", "length_height", "smallest_area"))
the data comes from here (all are float values):(this is the return signature of get_data_from_object)
return corners, parts, sharp, steep, flat, flat_count, over_air, object_overhang, bridges, thin, total_area, length_width, length_height, smallest_area
ive tried combining them like this:
csv_objects.loc[csv_objects.index.size]=result.loc[0]
or like this:
csv_objects.append(result)
code to reproduce the issue:
data = [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
return_array = pd.DataFrame(data=np.reshape(data, (1, 14)),
columns=("corners", "parts", "sharp", "steep",
"flat","flat_count", "over_air", "object_overhang", "bridges", "thin",
"total_area", "length_width", "length_height", "smallest_area"))
return_array.to_csv(path + "/save.csv")
csv_objects = pd.read_csv(path + "/save.csv")
result = pd.DataFrame(data=np.reshape(data, (1, 14)),
columns=("corners", "parts", "sharp", "steep",
"flat","flat_count", "over_air", "object_overhang", "bridges", "thin",
"total_area", "length_width", "length_height", "smallest_area"))
csv_objects.loc[csv_objects.index.size]=result.loc[0]
print(csv_objects)
but it always creates a new indexing column, so the resulting dataframe has 16 columns even though the old frames have 15 each (14 values and 1 index), which is not what i want. how can i prevent that and make them use the same index value? meaning, i need the new frames first row to start at the old frames last index value.
When i print the singular frames, it looks like this: [1 rows x 15 columns] Unnamed: 0 corners parts ... length_width length_height smallest_area 0 0 0.0 0.0 ... 1.0 0.5 1.0
when i print the combined frame, like this: [1 rows x 16 columns] Unnamed: 0 Unnamed: 0.1 ... length_height smallest_area 1 1 NaN ... 0.5 1.0