chrisdev/django-pandas

read_frame support property on django models..

Opened this issue · 6 comments

class MyModel(models.Model):

full_name = models.CharField(max_length=25)
age = models.IntegerField()
department = models.CharField(max_length=3)
wage = models.FloatField()

@property
def d1():
    return "1"

df = read_frame(qs, fieldnames=['age', 'wage', 'full_name', 'd1'],)

return
cannot' resolve keyword d1 into fields...

+1 I am struggling with the same. I have a field using jsonb in Postgres. I need a property which could extract the specific text from that. Properties support is a must

@hipertracker2 maybe we could do this on our fork ...

@hipertracker2 sorry for not responding sooner. Project conflicts are winding down so probably i'll have more time to work on these issues. I guess we could introspect to see if it a property and resolve it into a pandas object. I'll be really happy to take a PR on this 👍

This would be really cool. There have been a bunch of other issues raising this that got closed because qs.values_list() doesn't support callables, but it would be nice to be able to pass callables in transparently, e.g. to pivot_table as a col or row field. Has anyone made any progress with this?

@benwhalley have you tried theto_pivot_table method?
I recall that @hipertracker2 @tyang were supposed to be forking the project to address the callable issue. In my workflow I get the dataframe back and then apply the callable

This would be really cool. There have been a bunch of other issues raising this that got closed because qs.values_list() doesn't support callables, but it would be nice to be able to pass callables in transparently, e.g. to pivot_table as a col or row field. Has anyone made any progress with this?

some progress is made by me, I end up using db views directly, move those logic into database instead of ORM seems more efficent, because ORM is framework related ,once the team migrate to new framework. Old codes needs to be rewrite and ends up with bunch of dirty work. @chrisdev