let assume i got an pd dataframe, i want it to cooperate with sqlachemy model to erase…
Jump to turn (7)
- 1let assume i got an pd dataframe, i want it to cooperate with sqlachemy model to
- 2what if the coltoremove function had been removed, any altertive plan to perform
- 3pd df print col
- 4dataframe check one field word length , if longer than 5length, print it
- 5now my dataframe is ready, how to suit into the sqlalchemy model
- 6panda read excel, rename col on all sheet
- 7beforecol = df.columns aftercol = df.columns make differences of above 2 var
- User
let assume i got an pd dataframe, i want it to cooperate with sqlachemy model to erase some field in the dataframe, for further step to insert into the db table
- Assistant
Assuming you want to remove a column from a DataFrame before loading the data into a SQLAlchemy model, you can use the
dropfunction provided by pandas.For example, if you have a DataFrame called
dfand you want to remove a column calledcol_to_remove, you can use the following code:pythondf = df.drop(columns=['col_to_remove'])After this, the
dfDataFrame will no longer have thecol_to_removecolumn.You can then create a new SQLAlchemy model instance using the updated DataFrame and insert it into the database table.
- User