15
I have a table with ~80k rows with imported data. Table structure is as follows:
order_line_items
- id
- order_id
- product_id
- quantity
- price
- uuid
On import, the order_id, product_id, quantity, and price were imported, but the uuid field was left null.
Is there a way, using python’s UUID() function, to add a uuid to each row of the table in bulk? I could use a script to cycle through each row and update it but if there is a python solution, that would be fastest.
3
Answers
A more Pythonic way in adding/modifying a value in a column is by using
map
method. You can find refer here for more details: https://pandas.pydata.org/docs/reference/api/pandas.Series.map.html.Basically, what
map
is doing is map values of a column according to an function.Your function must return a value for this to works, and you can take in the original value in the column as argument.
I’m fairly certain you can do this directly in MySQL using the UUID function.
Probably you need to add the default uuid for the table/model and and save value