Is there way to generate random data in pandas dataframe based on SQL data types and insert record types

Keywords: python pandas random-data

Question: 

I have df like below,

+----+----------------+--------------+
|    |  column_name   |  data_type   |
+----+----------------+--------------+
|  0 | time           | TIMESTAMP    |
|  1 | id             | VARCHAR(8)   |
|  2 | operation_flag | VARCHAR(1)   |
|  3 | userid         | VARCHAR(11)  |
| 12 | Amount         | DECIMAL(6,2) |
| 15 | address        | STRING       |
+----+----------------+--------------+

I'm trying to get df like where,

date=2019-05-12(to generate random date timestamp for 'time' column within 2019-05-12 date) no_of_insert_record=3(to set operational flag row as default 'I') no_of_delete_record=2(to set operational flag row as default 'X')

+---+----------------+--------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
|   |  column_name   |  data_type   |           col_1            |           col_2            |           col_3            |           col_4            |           col_5            |
+---+----------------+--------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
| 0 | time           | TIMESTAMP    | 2019-05-16 19:12:38.000000 | 2019-05-16 13:12:38.000000 | 2019-05-16 14:12:38.000000 | 2019-05-16 09:12:38.000000 | 2019-05-16 21:12:38.000000 |
| 1 | id             | VARCHAR(8)   | dsADv                      | sadfD                      | Dcads                      | Aadf                       | Faed                       |
| 2 | operation_flag | VARCHAR(1)   | I                          | I                          | I                          | X                          | X                          |
| 3 | userid         | VARCHAR(11)  | shdjAdf                    | dsacDA                     | adFAf                      | ADFCc                      | fdcdA                      |
| 4 | Amount         | DECIMAL(6,2) | 3452.34                    | 2343.23                    | 5345.21                    | 4212.11                    | 4231.45                    |
| 5 | address        | STRING       | dasfADdvc                  | wdsdsgf                    | adgfn                      | aWAdcavb                   | afaavb                     |
+---+----------------+--------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+

Answers: