Я пытаюсь загрузить данные CSV в таблицу MySQL, но в моем CSV есть несколько пустых столбцов, и когда я загружаю в CSV все данные до загрузки пустых столбцов, но после этого загрузка CSV получает остановку
for i in range(m * chunksize, (m * chunksize) + chunksize):
company = pd.isnull(df.loc[i]['company'] or df.loc[i]['name'] or df.loc[i]['observed_sales'] or df.loc[i]['observed_transactions'])
if company == True :
df.loc[i]['company'] = ''
df.loc[i]['name'] = ''
y = np.nan_to_num(df.loc[i]['observed_sales'])
z = np.nan_to_num(df.loc[i]['observed_transactions'])
df.loc[i]['observed_sales'] = df.loc[i]['observed_sales'].replace('nan', np.nan).interpolate(0.0)
df.loc[i]['observed_transactions'] = df.loc[i]['observed_transactions'].replace('nan', np.nan).interpolate(0.0)
Company.objects.update_or_create(company_name=df.loc[i]['company'], company_full_name=df.loc[i]['name'], website_url=df.loc[i]['website'])
obj = Company.objects.latest('company_id')
id = obj.company_id
TransactionDetails_Monthly.objects.update_or_create(company_id=id, observed_sales=y, observed_transactions=z, observed_customers=df.loc[i]['observed_customers'], sales_per_customer=df.loc[i]['sales_per_customer'], txns_per_customer=df.loc[i]['txns_per_customer'], avg_txn_value=df.loc[i]['avg_txn_value'], month=df.loc[i]['month'])
msg = "Data is inserted successfully"
Я сталкиваюсь с этой ошибкой [невозможно преобразовать число с плавающей запятой в целое число)
, и я также хочу показать свои models.py
class Company(models.Model):
company_id = models.AutoField(primary_key=True)
category = models.ForeignKey('Category', on_delete=models.CASCADE, null=True) #ForeignKey
company_name = models.CharField(max_length=255,null=True)
company_full_name = models.CharField(max_length=255, null=True)
company_name_url = models.CharField(max_length=255, null=True)
website_url = models.CharField(max_length=255, null=True)
founded_date = models.DateField(null=True)
founded_date_precision = models.DateField(null=True)
total_funding_amount = models.DecimalField(max_digits=13, decimal_places=2, null=True)
total_funding_amount_currency = models.DecimalField(max_digits=13, decimal_places=2, null=True)
total_funding_amount_currency_usd = models.DecimalField(max_digits=13, decimal_places=2, null=True)
class TransactionDetails_Monthly(models.Model):
transaction_id = models.AutoField(primary_key=True)
company = models.ForeignKey('Company' , on_delete = models.CASCADE, null=True) #ForeignKey
month = models.DateField()
observed_sales = models.IntegerField()
observed_transactions = models.IntegerField()
observed_customers = models.IntegerField()
sales_per_customer = models.FloatField(null=True)
txns_per_customer = models.FloatField(null=True, blank=True, default=None)
avg_txn_value = models.DecimalField(max_digits=13, decimal_places=2, blank=True, null=True)