Я пытаюсь загрузить фрейм данных в базу данных sqlite, у которой нет проблем, если я не добавлю столбец 'четверти'.
df['quarters'] = pd.PeriodIndex(pd.df(empres_df.date), freq='Q')
df.to_sql("table_name", con, if_exists="append")
Потому что, когда я это делаю, она выдает мне эту ошибку:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/anaconda3/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/mkhumtai/Desktop/IndividualProject/avian/app/views.py", line 145, in import_data
empres_df.to_sql("empres", con, if_exists="append")
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 2712, in to_sql
method=method,
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 518, in to_sql
method=method,
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 1747, in to_sql
dtype=dtype,
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 1440, in __init__
super().__init__(*args, **kwargs)
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 619, in __init__
self.table = self._create_table_setup()
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 1476, in _create_table_setup
column_names_and_types = self._get_column_names_and_types(self._sql_type_name)
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 860, in _get_column_names_and_types
for i in range(len(self.frame.columns))
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 860, in <listcomp>
for i in range(len(self.frame.columns))
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/io/sql.py", line 1532, in _sql_type_name
col_type = lib.infer_dtype(col, skipna=True)
File "pandas/_libs/lib.pyx", line 1246, in pandas._libs.lib.infer_dtype
ValueError: cannot infer type for <class 'NoneType'>
Добавление столбца 'четверти' в сам фрейм данных не выдает ошибку, пока я не не включать этот столбец в базу данных.
Как это исправить?