holoviz / holoviz/datashader

Line Plot with Grouped Dataframes

Open
#257 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
3.6k
Forks
376
Avg merge
4h 32m
Merged PRs (30d)
1

Description

I would like to visualize flight tracks around an airport and aggregate them as line-objects instead of point data. The issue I have been running into is that importing the CSV data into a Pandas dataframe and grouping the data based on a flight track identifier ('Msn') is not compatible with datashader's aggregation capabilities.

```
df = pd.read_csv("data_trim_small.csv")
dfg = df.groupby('Msn')
cvs = ds.Canvas(plot_width=plot_width, plot_height=plot_height, x_range=x_range, y_range=y_range)
agg = cvs.line(dfg, 'Long', 'Lat', ds.count())

# NotImplementedError: Don't know how to discover type 'DataFrameGroupBy'
```

There are too many different flight tracks to set each track as its own category (memory issues). Below are the results:
![flight_vis_bos_line](https://cloud.githubusercontent.com/assets/23238612/19967267/fd325d34-a1a5-11e6-99dc-dcc36ce273d1.png)
![flight_vis_bos_pts](https://cloud.githubusercontent.com/assets/23238612/19967268/fd34d622-a1a5-11e6-98b9-701e74b5110b.png)
Note that the spoke-like lines at the gate should not be there as shown in the points density map.

I did have some success with creating an OrderedDict of line objects and summing over them:
```
agg = OrderedDict((ii, cvs.line(df.loc[df['Msn']==Msn_uniq[ii]], 'Long', 'Lat')) for ii in range(0,Msn_tot))
agg_sum = sum(agg.values())
tf.shade(agg_sum, cmap=inferno)
```
However, the workaround is rather inefficient. Is there a specific datastructure I should be using instead?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the pandas DataFrameGroupBy input with Canvas.line, then compare it with the OrderedDict workaround described in the issue. Done means grouped flight tracks can be aggregated efficiently without per-track category memory costs or the unwanted spoke-like lines; the payload names no repository file or test to target.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.