23-04-2021



Docker let you to do it with the help of port forwarding. First run docker ps -a, find your container id, usually the very first column and then run the command like docker port 8dbfe2506534 where 8dbfe2506534 is my container id. Even if you just do a docker ps -a you can see how a port is being. The Docker extension provides a docker debug configuration provider that manages how VS Code will launch an application and/or attach a debugger to the application in a running Docker container. This provider is configured via entries within launch.json, with configuration being specific to each application platform supported by the provider.

Latest version

Released:

Tools for working with pydata.pandas in your Django projects

Project description

Tools for working with pandas in your Djangoprojects

Contributors

What’s New

Version 0.6.4 supports the latest release of Pandas (1.2.1)

Dependencies

django-pandas supports Django (>=1.4.5) or laterand requires django-model-utils (>= 1.4.0) and Pandas (>= 0.12.0).Note because of problems with the requires directive of setuptoolsyou probably need to install numpy in your virtualenv before you installthis package or if you want to run the test suite

Some pandas functionality requires parts of the Scipy stack.You may wish to consult http://www.scipy.org/install.htmlfor more information on installing the Scipy stack.

You need to install your preferred version of Django.as that Django 2 does not support Python 2.

Contributing

Please file bugs and send pull requests to the GitHub repository and issuetracker.

Installation

Start by creating a new virtualenv for your project

Next install numpy and pandas and optionally scipy

You may want to consult the scipy documentation for more informationon installing the Scipy stack.

Finally, install django-pandas using pip:

or install the development version from github

Usage

IO Module

The django-pandas.io module provides some convenience methods tofacilitate the creation of DataFrames from Django QuerySets.

read_frame

Parameters

  • qs: A Django QuerySet.
  • fieldnames: A list of model field names to use in creating the DataFrame.
    You can span a relationship in the usual Django wayby using double underscores to specify a related fieldin another model
  • index_col: Use specify the field name to use for the DataFrame index.
    If the indexfield is not in the field list it will be appended
  • coerce_float :Boolean, defaults to True
    Attempt to convert values to non-string,non-numeric objects (like decimal.Decimal)to floating point.
  • verbose: If this is True then populate the DataFrame with the
    human readable versions of any foreign key or choice fieldselse use the actual values set in the model.
  • column_names: If not None, use to override the column names in the
    DateFrame

Examples

Assume that this is your model:

First create a query set:

To create a dataframe using all the fields in the underlying model

The df will contain human readable column values for foreign key and choicefields. The DataFrame will include all the fields in the underlyingmodel including the primary key.To create a DataFrame using specified field names:

To set full_name as the DataFrame index

You can use filters and excludes

DataFrameManager

django-pandas provides a custom manager to use with models thatyou want to render as Pandas Dataframes. The DataFrameManagermanager provides the to_dataframe method that returnsyour models queryset as a Pandas DataFrame. To use the DataFrameManager, firstoverride the default manager (objects) in your model’s definitionas shown in the example below

This will give you access to the following QuerySet methods:

  • to_dataframe
  • to_timeseries
  • to_pivot_table

to_dataframe

Returns a DataFrame from the QuerySet

Parameters

  • fieldnames: The model field names to utilise in creating the frame.
    to span a relationship, use the field name of relatedfields across models, separated by double underscores,
  • index: specify the field to use for the index. If the index
    field is not in the field list it will be appended
  • coerce_float: Attempt to convert the numeric non-string data
    like object, decimal etc. to float if possible
  • verbose: If this is True then populate the DataFrame with the
    human readable versions of any foreign key or choice fieldselse use the actual value set in the model.

Examples

Create a dataframe using all the fields in your model as follows

This will include your primary key. To create a DataFrame using specifiedfield names:

To set full_name as the index

You can use filters and excludes

to_timeseries

A convenience method for creating a time series i.e theDataFrame index is instance of a DateTime or PeriodIndex

Parameters

  • fieldnames: The model field names to utilise in creating the frame.
    to span a relationship, just use the field name of relatedfields across models, separated by double underscores,
  • index: specify the field to use for the index. If the index
    field is not in the field list it will be appended. Thisis mandatory.
  • storage: Specify if the queryset uses the wide or long format
    for data.
  • pivot_columns: Required once the you specify long format
    storage. This could either be a list or string identifyingthe field name or combination of field. If the pivot_columnis a single column then the unique values in this column becomea new columns in the DataFrameIf the pivot column is a list the values in these columns areconcatenated (using the ‘-‘ as a separator)and these values are used for the new timeseries columns
  • values: Also required if you utilize the long storage the
    values column name is use for populating new frame values
  • freq: the offset string or object representing a target conversion
  • rs_kwargs: Arguments based on pandas.DataFrame.resample
  • verbose: If this is True then populate the DataFrame with the
    human readable versions of any foreign key or choice fieldselse use the actual value set in the model.

Examples

Using a long storage format

Django Docker Setup Windows

Some sample data::

Create a QuerySet

Create a timeseries dataframe

Using a wide storage format

to_pivot_table

A convenience method for creating a pivot table from a QuerySet

Parameters

  • fieldnames: The model field names to utilise in creating the frame.
    to span a relationship, just use the field name of relatedfields across models, separated by double underscores,
  • values : column to aggregate, optional
  • rows :list of column names or arrays to group on
    Keys to group on the x-axis of the pivot table
  • cols :list of column names or arrays to group on
    Keys to group on the y-axis of the pivot table
  • aggfunc :function, default numpy.mean, or list of functions
    If list of functions passed, the resulting pivot table will havehierarchical columns whose top level are the function names(inferred from the function objects themselves)
  • fill_value :scalar, default None
    Value to replace missing values with
  • margins :boolean, default False
    Add all row / columns (e.g. for subtotal / grand totals)
  • dropna : boolean, default True

Example

Usage

CHANGES

0.6.4 (2021-02-08)

Bumped version number as the previous release was incorrectly uploadedto pypi

0.6.1 (2020-05-26)

Supports the latest release of Pandas 1.0.3

0.6.0 (2019-01-11)

Removes compatibility with Django versions < 1.8

0.5.2 (2019-01-3)

Django Docker Setup

Django Docker Setup Ubuntu

This is the last version that supports Django < 1.8

  • Improved coerce_float option (thanks @ZuluPro )
  • Ensure compatibility with legacy versions of Django ( < 1.8)
  • Test pass with Django 2+ and python 3.7

0.5.1 (2018-01-26)

  • Address Unicode decode error when installing with pip3 on docker (Thanks @utapyngo)

0.5.0 (2018-01-20)

  • Django 2.0 compatibility (Thanks @meirains)

0.4.5 (2017-10-4)

  • A Fix for fieldname deduplication bug thanks to @kgabbott

0.4.4 (2017-07-16)

  • The verbose argument now handles more use cases (Thanks to @henhuy andKevin Abbott)
  • Corece float argument add to `to_timeseries()` method (Thanks Yousuf Jawwad)

0.4.3 (2017-06-02)

  • Fix doc typos and formatting
  • Prevent column duplication in read_frame (Thanks Kevin Abbott)

0.4.2 (2017-05-22)

  • Compatibility with pandas 0.20.1
  • Support for Python 2.7 and 3.5 with Django versions 1.8+
  • Suport for Python 3.6 and Django 1.11
  • We still support legacy versions (Python 2.7 and Django 1.4)

0.4.1 (2016-02-05)

Django docker settings.py
  • Address the incompatibility with Django 1.9 due to the removal ofspecialized query sets like theValuesQuerySet
  • Address the removal of the PassThrougManager from django-model-utilsversion 2.4. We’ve removed the dependency on django-model-utils andincluded the PassThroughManger (which was always a standalone tooldistributed a part of django-model-utils) for compatibility withearlier versions of Django (<= 1.8). For more recent versions ofDjango we’re using Django’s built in QuerySet.as_manager().
  • Now supports Pandas 0.14.1 and above
  • The fall in Coverage in this release largely reflects the integration ofthe PassThroughManager into the code base. We’ll add the required testcoverage for the PassThroughManager in subsequent releases.

0.3.1 (2015-10-25)

  • Extends the ability to span a ForeignKey relationship with double underscoresto OneToOneField too thanks to Safe Hammad
  • Provide better support for ManyToMany and OneToMany relations thanks toJeff Sternberg and @MiddleFork

0.3.0 (2015-06-16)

  • This version supports Django 1.8
  • Support for Pandas 0.16

0.2.1 (2015-01-28)

  • Added Support for Values QuerySets
  • Support for Python 2.6
  • Note we still have limited support for Django 1.7 but this will be coming inthe next release

0.2.0 (2014-06-15)

  • Added the io module so that DataFrames can be created from anyqueryset so you don’t need to to add a DataFrame manager to yourmodels. This is good for working with legacy projects.
  • added a Boolean verbose argument to all methods (which defaults to True)This populate the DataFrame columns with the human readable versions offoreign key or choice fields.
  • Improved the performance DataFrame creation by removing dependency onnp.core.records.fromrecords
  • Loads of bug fixes, more tests and improved coverage and betterdocumentation

Release historyRelease notifications | RSS feed

0.6.4

0.6.3 yanked

0.6.2

0.6.1

0.6.0

0.5.2

0.5.1

0.5.0

0.4.5

0.4.4

0.4.3

0.4.2

0.4.1

0.3.1

0.3.0

Django Docker Setup

0.2.2

0.2.1

0.2.0

Setup

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-pandas, version 0.6.4
Filename, sizeFile typePython versionUpload dateHashes
Filename, size django_pandas-0.6.4-py3-none-any.whl (21.3 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size django-pandas-0.6.4.tar.gz (32.1 kB) File type Source Python version None Upload dateHashes
Close

Hashes for django_pandas-0.6.4-py3-none-any.whl

Hashes for django_pandas-0.6.4-py3-none-any.whl
AlgorithmHash digest
SHA256ccb3c5b9e201515c5247266227b22d7307a1e3f8b1c02c3844a985f367b8f199
MD5db07c4391a90400232bf5a2a86be84d5
BLAKE2-25657eb41695f91e76f30e57b519c79c9a6326f852cbcee6373c1e1cf874985512d
Close

Hashes for django-pandas-0.6.4.tar.gz

Hashes for django-pandas-0.6.4.tar.gz
AlgorithmHash digest
SHA256a1b5d300112a09625926a5756aa72bbe8918fb95b9c4ec39b3a06f03e0e336f9
MD5f2562a724e9e4782f1b16942d87ef704
BLAKE2-256bcff0faa4f7225591a5b04806c805d1f6d567c0da6fa8e904e8209cfc6c83fa5