You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
Django REST Pandas
2
2
==================
3
3
4
-
#### [Django REST Framework] + [Pandas] = A Model-driven Visualization API
4
+
#### [Django REST Framework] + [pandas] = A Model-driven Visualization API
5
5
6
-
**Django REST Pandas** (DRP) provides a simple way to generate and serve [Pandas] DataFrames via the [Django REST Framework]. The resulting API can serve up CSV (and a number of [other formats](#supported-formats)) for consumption by a client-side visualization tool like [d3.js].
6
+
**Django REST Pandas** (DRP) provides a simple way to generate and serve [pandas] DataFrames via the [Django REST Framework]. The resulting API can serve up CSV (and a number of [other formats](#supported-formats)) for consumption by a client-side visualization tool like [d3.js].
7
7
8
8
The design philosophy of DRP enforces a strict separation between data and presentation. This keeps the implementation simple, but also has the nice side effect of making it trivial to provide the source data for your visualizations. This capability can often be leveraged by sending users to the same URL that your visualization code uses internally to load the data.
9
9
@@ -21,12 +21,12 @@ The [climata-viewer] project uses Django REST Pandas and [wq/chart.js] to provid
21
21
## Related Work
22
22
The field of Python-powered data analysis and visualization is growing, and there are a number of similar solutions that may fit your needs better.
23
23
24
-
*[Django Pandas] provides a custom ORM model manager with Pandas support. By contrast, Django REST Pandas works at the *view* level, by integrating Pandas via custom Django REST Framework serializers and renderers.
25
-
*[DRF-CSV] provides straightforward CSV renderers for use with Django REST Framework. It may be useful if you just want a CSV API and don't have a need for the Pandas DataFrame functionality.
24
+
*[Django Pandas] provides a custom ORM model manager with pandas support. By contrast, Django REST Pandas works at the *view* level, by integrating pandas via custom Django REST Framework serializers and renderers.
25
+
*[DRF-CSV] provides straightforward CSV renderers for use with Django REST Framework. It may be useful if you just want a CSV API and don't have a need for the pandas DataFrame functionality.
26
26
*[mpld3] provides a direct bridge from [matplotlib] to [d3.js], complete with seamless [IPython] integration. It is restricted to the (large) matplotlib chart vocabularly but should be sufficient for many use cases.
27
27
*[Bokeh] is a complete client-server visualization platform. It does not leverage d3 or Django, but is notable as a comprehensive, forward-looking approach to addressing similar use cases.
28
28
29
-
The goal of Django REST Pandas is to provide a generic REST API for serving up Pandas dataframes. In this sense, it is similar to the Plot Server in Bokeh, but more generic in that it does not assume any particular visualization format or technology. Further, DRP is optimized for integration with public-facing Django-powered websites (unlike mpld3 which is primarily intended for use within IPython).
29
+
The goal of Django REST Pandas is to provide a generic REST API for serving up pandas dataframes. In this sense, it is similar to the Plot Server in Bokeh, but more generic in that it does not assume any particular visualization format or technology. Further, DRP is optimized for integration with public-facing Django-powered websites (unlike mpld3 which is primarily intended for use within IPython).
30
30
31
31
In summary, DRP is designed for use cases where:
32
32
@@ -37,7 +37,7 @@ In summary, DRP is designed for use cases where:
37
37
38
38
The following output formats are provided by default. These are provided as [renderer classes] in order to leverage the content type negotiation built into Django REST Framework. This means clients can specify a format via `Accepts: text/csv` or by appending `.csv` to the URL (if the URL configuration below is used).
39
39
40
-
Format | Content Type | Pandas DataFrame Function | Notes
40
+
Format | Content Type | pandas DataFrame Function | Notes
The default `PandasView` will serve up all of the available data from the provided model in a simple tabular form. You can also use a `PandasViewSet` if you are using Django REST Framework's [ViewSets] and [Routers], or a `PandasSimpleView` if you would just like to serve up some data without a Django model as the source.
111
111
112
112
### Implementation Notes
113
-
The underlying implementation is a set of [serializers] that take the normal serializer result and put it into a dataframe. Then, the included [renderers] generate the output using the built in Pandas functionality.
113
+
The underlying implementation is a set of [serializers] that take the normal serializer result and put it into a dataframe. Then, the included [renderers] generate the output using the built in pandas functionality.
114
114
115
-
Perhaps counterintuitively, the CSV renderer is the default in Django REST Pandas, as it is the most stable and useful for API building. While the Pandas JSON serializer is improving, the primary reason for making CSV the default is the compactness it provides over JSON when serializing time series data. This is particularly valuable for Pandas dataframes, in which:
115
+
Perhaps counterintuitively, the CSV renderer is the default in Django REST Pandas, as it is the most stable and useful for API building. While the pandas JSON serializer is improving, the primary reason for making CSV the default is the compactness it provides over JSON when serializing time series data. This is particularly valuable for pandas dataframes, in which:
116
116
117
117
- each record has the same keys, and
118
118
- there are (usually) no nested objects
119
119
120
-
While a normal CSV file only has a single row of column headers, Pandas can produce files with nested columns. This is a useful way to provide metadata about time series that is difficult to represent in a plain CSV file. However, it also makes the resulting CSV more difficult to parse. For this reason, you may be interested in [wq/pandas.js], a d3 extension for loading the complex CSV generated by Pandas Dataframes.
120
+
While a normal CSV file only has a single row of column headers, pandas can produce files with nested columns. This is a useful way to provide metadata about time series that is difficult to represent in a plain CSV file. However, it also makes the resulting CSV more difficult to parse. For this reason, you may be interested in [wq/pandas.js], a d3 extension for loading the complex CSV generated by pandas Dataframes.
121
121
122
122
```javascript
123
123
// mychart.js
@@ -141,7 +141,7 @@ function render(error, data) {
141
141
You can override the default renderers by setting `PANDAS_RENDERERS` in your `settings.py`, or by overriding `renderer_classes` in your `PandasView` subclass. `PANDAS_RENDERERS` is intentionally set separately from Django REST Framework's own `DEFAULT_RENDERER_CLASSES` setting, as it is likely that you will be mixing DRP views with regular DRF views.
0 commit comments