Coder Social home page Coder Social logo

Comments (6)

chrisdev avatar chrisdev commented on August 15, 2024

Hi.
Just back from some time off. Looks like we have to do some rewriting for Python 3.9??

from django-pandas.

jayvdb avatar jayvdb commented on August 15, 2024

This also occurred on Python 3.7

from django-pandas.

mcepl avatar mcepl commented on August 15, 2024

And 3.8.:

[   40s] + PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python-django-pandas-0.6.2-0.x86_64/usr/lib/python3.8/site-packages
[   40s] + python3.8 runtests.py
[   41s] /home/abuild/rpmbuild/BUILD/django-pandas-0.6.2/django_pandas/tests/test_manager.py:10: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
[   41s]   import pandas.util.testing as tm
[   41s] Creating test database for alias 'default'...
[   41s] System check identified some issues:
[   41s]
[   41s] WARNINGS:
[   41s] tests.Car: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.DataFrame: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.Dude: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.LongTimeSeries: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.MyModel: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.MyModelChoice: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.PivotData: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.Portfolio: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.Security: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.Spot: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.TradeLog: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.TradeLogNote: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.Trader: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.WideTimeSeries: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s] tests.WideTimeSeriesDateField: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
[   41s] 	HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
[   41s]
[   41s] System check identified 15 issues (0 silenced).
[   41s] ........E...........
[   41s] ======================================================================
[   41s] ERROR: test_verbose (django_pandas.tests.test_io.RelatedFieldsTest)
[   41s] ----------------------------------------------------------------------
[   41s] Traceback (most recent call last):
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1823, in get_prep_value
[   41s]     return int(value)
[   41s] ValueError: cannot convert float NaN to integer
[   41s]
[   41s] The above exception was the direct cause of the following exception:
[   41s]
[   41s] Traceback (most recent call last):
[   41s]   File "/home/abuild/rpmbuild/BUILD/django-pandas-0.6.2/django_pandas/tests/test_io.py", line 143, in test_verbose
[   41s]     df = read_frame(qs, verbose=True)
[   41s]   File "/home/abuild/rpmbuild/BUILD/django-pandas-0.6.2/django_pandas/io.py", line 128, in read_frame
[   41s]     update_with_verbose(df, fieldnames, fields)
[   41s]   File "/home/abuild/rpmbuild/BUILD/django-pandas-0.6.2/django_pandas/utils.py", line 83, in update_with_verbose
[   41s]     df[fieldname] = function(df[fieldname])
[   41s]   File "/home/abuild/rpmbuild/BUILD/django-pandas-0.6.2/django_pandas/utils.py", line 57, in inner
[   41s]     for obj in model.objects.filter(
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
[   41s]     return getattr(self.get_queryset(), name)(*args, **kwargs)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/query.py", line 941, in filter
[   41s]     return self._filter_or_exclude(False, args, kwargs)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
[   41s]     clone._filter_or_exclude_inplace(negate, args, kwargs)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
[   41s]     self._query.add_q(Q(*args, **kwargs))
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1393, in add_q
[   41s]     clause, _ = self._add_q(q_object, self.used_aliases)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1412, in _add_q
[   41s]     child_clause, needed_inner = self.build_filter(
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1347, in build_filter
[   41s]     condition = self.build_lookup(lookups, col, value)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1193, in build_lookup
[   41s]     lookup = lookup_class(lhs, rhs)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/lookups.py", line 25, in __init__
[   41s]     self.rhs = self.get_prep_lookup()
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/lookups.py", line 240, in get_prep_lookup
[   41s]     rhs_value = self.lhs.output_field.get_prep_value(rhs_value)
[   41s]   File "/usr/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1825, in get_prep_value
[   41s]     raise e.__class__(
[   41s] ValueError: Field 'id' expected a number but got nan.
[   41s]
[   41s] ----------------------------------------------------------------------
[   41s] Ran 20 tests in 0.502s
[   41s]
[   41s] FAILED (errors=1)

from django-pandas.

graingert avatar graingert commented on August 15, 2024

Hi. Just back from some time off. Looks like we have to do some rewriting for Python 3.9??

hello it looks like this on just a newer version of pandas:

on Python3.6 (pandas 1.1.5):

(Pdb) import pandas
(Pdb) pandas
<module 'pandas' from '/home/graingert/projects/django-pandas/.tox/py3.6-django32/lib/python3.6/site-packages/pandas/__init__.py'>
(Pdb) pandas.__version__
'1.1.5'
-> pk_series = pk_series.where(pk_series.notnull(), None)
(Pdb) pk_series
0    NaN
1    NaN
2    1.0
3    1.0
4    2.0
5    2.0
6    2.0
7    2.0
Name: symbol, dtype: float64
(Pdb) pk_series.where(pk_series.notnull(), None)
0    None
1    None
2       1
3       1
4       2
5       2
6       2
7       2
Name: symbol, dtype: object

however on pandas 1.3.3 and python 3.9.7 you get:

Python 3.9.7 (default, Sep  9 2021, 23:20:13) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> pk_series = pandas.read_csv(io.StringIO(',symbol\n0,\n1,\n2,1.0\n3,1.0\n4,2.0\n5,2.0\n6,2.0\n7,2.0\n')).symbol
>>> pk_series
0    NaN
1    NaN
2    1.0
3    1.0
4    2.0
5    2.0
6    2.0
7    2.0
Name: symbol, dtype: float64
>>> pk_series.notnull()
0    False
1    False
2     True
3     True
4     True
5     True
6     True
7     True
Name: symbol, dtype: bool
>>> pk_series.where(pk_series.notnull(), None)
0    NaN
1    NaN
2    1.0
3    1.0
4    2.0
5    2.0
6    2.0
7    2.0
Name: symbol, dtype: float64
>>> pandas.__version__
'1.3.3'

from django-pandas.

graingert avatar graingert commented on August 15, 2024

pandas 1.2.5 has the old behaviour

from django-pandas.

graingert avatar graingert commented on August 15, 2024

https://stackoverflow.com/questions/14162723/replacing-pandas-or-numpy-nan-with-a-none-to-use-with-mysqldb#comment120691138_14163209

from django-pandas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.