<jupyter_start><jupyter_text>Analyzing Spatial Trajectories with TrajaFull documentation is available at [traja.readthedocs.io](http://traja.readthedocs.io).<jupyter_code>!pip install traja
import traja
# Create sample random walk
df = traja.generate()

# Visualize x and y values with built-in pandas methods
df.plot()<jupyter_output><empty_output><jupyter_text>Plot Trajectory  Plot trajectory with traja accessor method (`.traja.plot()`)<jupyter_code>fig = df.traja.plot()<jupyter_output><empty_output><jupyter_text>Visualize distribution of angles and turn-angles<jupyter_code>df.traja.calc_angle().hist() # with regard to x-axis
df.traja.calc_turn_angle().hist() # deviation from strait ahead<jupyter_output><empty_output><jupyter_text>Visualize flow between grid units<jupyter_code>for kind in ['stream', 'quiver', 'contourf']:
    fig = df.traja.plot_flow(kind=kind)<jupyter_output><empty_output><jupyter_text>Visualize distribution of turn angles over time<jupyter_code>df.traja.calc_turn_angle().plot()
for log in [True, False]:
    for bins in [8, 32]:
        print(f"Bins: {bins}")
        df.traja.trip_grid(bins=bins, log=log)<jupyter_output>Bins: 8<jupyter_text>Plot polar bar chart showing turn preference<jupyter_code>traja.plotting.polar_bar(df)
# Show non-overlapping histogram
traja.plotting.polar_bar(df, overlap=False)<jupyter_output>/Users/justinshenk/Projects/mousetrack/traja/plotting.py:745: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  trj["turn_angle"] = feature_series
/Users/justinshenk/anaconda3/envs/traja/lib/python3.6/site-packages/pandas/core/generic.py:5096: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self[name] = value<jupyter_text>Resample Trajectory<jupyter_code># Resample to arbitrary step length (here, 20 meters)
fig = df.traja.rediscretize(R=20).traja.plot()
# Resample to arbitrary time (here, 1 second)
fig = df.traja.resample_time(step_time='1s').traja.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11440501043841336, 'fraction_numerical': 0.008350730688935281, 'mean_word_length': 6.5109717868338555, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '339494', 'license': 'MIT', 'n_tokens_mistral': 879, 'n_tokens_neox': 846, 'n_words': 179, 'path': 'demo.ipynb', 'repo_name': 'alexlib/traja', 'size': '2395'}