plotly / plotly/plotly.py

Plot DataFrame with TimedeltaIndex (x-axis)

オープン
#799 コメント 15 件 リアクション 41 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

Hello,

Plotly.py doesn't display x axis well when using a TimedeltaIndex

import pandas as pd
from pandas.compat import StringIO
import plotly
from plotly.graph_objs import Scatter, Layout

dat = """millis;ax;ay;az
544;-5.65;-0.39;7.45
550;-4.79;-0.59;7.26
556;-4.79;-1.33;6.79
562;-0.63;-1.33;9.53
579;-4.63;0.16;7.96
599;-5.45;0.35;7.34
618;-5.18;1.88;3.77
637;-6.12;-2.00;9.92
658;-3.80;0.51;9.02
677;-4.35;0.04;9.53
697;-3.88;0.71;8.79
717;-4.86;-0.43;8.83
741;-4.16;-1.06;8.79
756;-3.57;0.31;7.92
777;-2.71;2.79;8.32
796;-2.43;5.53;10.55
816;-2.75;3.30;8.67
835;-2.12;2.47;7.85
856;-2.04;2.63;7.85
875;-2.31;2.31;8.04
894;-2.00;3.37;8.12
922;0.86;7.69;9.65
942;-1.45;5.26;8.75
961;-1.96;4.35;8.04
985;-1.80;3.77;8.36
1001;-1.61;3.10;8.55"""

df = pd.read_csv(StringIO(dat), sep=';')
df['millis'] = pd.to_timedelta(df['millis'], unit='ms')
df = df.set_index('millis')

df.index = df.index + pd.Timestamp("1970/01/01")

print(df)
print(df.dtypes)
print(df.index)

plotly.offline.plot({
"data": [
    Scatter(x=df.index, y=df['ax'])
],
"layout": Layout(
    title="DataFrame with %s" % str(type(df.index))
)
})

When using TimedeltaIndex I get

capture d ecran 2017-07-22 a 12 09 19

x-axis have odd values starting with P0D 0H0M0.

but when using a DatetimeIndex I get

capture d ecran 2017-07-22 a 12 16 44

It will be great if Plotly.py could handle TimedeltaIndex without hassle.

Kind regards

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供されている pandas TimedeltaIndex の再現から始め、Plotly.py がインデックス値を x 軸データに変換する処理を追跡します。示されている DatetimeIndex の出力に対して動作を確認します。完了の条件は、呼び出し元が手動で変換しなくても TimedeltaIndex が読みやすい x 軸の値をレンダリングすることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
pandas, plotly, python
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。