dimanche 20 novembre 2022

Hi I cant export the random created data in Python to SQL

Hi below code create random the data but I am not able to move it to excel or sql how can I do it ?

#import modules
import pandas as pd
import numpy as np
import random

Disease_type = ['Covid']
vaccine_type = ['Sinovac','Pfizer','AstraZeneca','Jonson']
dose_number = [1]
dfs = []

#create loop to randomly generate data
for x in np.arange(50):
    df_tmp = pd.DataFrame({
        "Date": np.random.choice(pd.date_range('2021-01-01', '2021-12-31', freq='D')),
        "card_id": random.randrange(4168427,5168472),
        "latitude": random.uniform(40.00,41.00),
        "Longitute": random.uniform(40.70,48.59),
        "disease type": [random.choice(Disease_type)],
        "vaccine type": [random.choice(vaccine_type)],
        "Dose number": random.randrange(1,2)
    })

    dfs.append(df_tmp)

#print the data
df = pd.concat(dfs).set_index("Date")
print(df)



Aucun commentaire:

Enregistrer un commentaire