I have a pandas dataframe with 10 rows and 5 columns and a numpy matrix of zeros np.zeros((10,3))
.
I want to concat the numpy matrix to the pandas dataframe but I want to delete the last column from the pandas dataframe before concatenating the numpy array to it.
So I will end up with a matrix of 10 rows and 5 - 1 + 3 = 7 columns.
I guess I could use
new_dataframe = pd.concat([
original_dataframe,
pd.DataFrame(np.zeros((10, 3)), dtype=np.int)
], axis=1, ignore_index=True)
where original_dataframe
has 10 rows and 5 columns.
How do I delete the last column from original_dataframe
before concatenating the numpy array? And how do I make sure I preserve all the data types?