【发布时间】:2021-01-19 13:54:05
【问题描述】:
我有 3 个 df 来自 3 台机器(Machine1/Machine2/Machine3)。每个 df 有 3 列。白班和生产。 样本df:
Day-Shift Production Quality
Day 11-01 20 A
Night 11-01 45 A
Day 11-02 65 A
Night 11-02 12 B
Day 11-03 97 B
我的代码:
import numpy as np
import pandas as pd
from plotly.offline import iplot
import plotly.graph_objects as go
# Machine1: Create numpy arrays of values for the given quality.
b1 = np.where(df1['Quality'] == 'A', df1['Production'], None)
# Machine2: Same as above.
b2 = np.where(df2['Quality'] == 'A', df2['Production'], None)
# Machine3: Same as above.
b3 = np.where(df3['Quality'] == 'A', df3['Production'], None)
# Setup.
t = []
line = ['solid']
Quality = ['A']
t.append({'x': df1['Day-Shift'],
'y': b1,
'name': f'Machine1',
'line': {'color': 'red',
'dash': line[0]}})
t.append({'x': df2['Day-Shift'],
'y': b2,
'name': f'Machine1',
'line': {'color': 'blue',
'dash': line[0]}})
t.append({'x': df3['Day-Shift'],
'y': b3,
'name': f'Machine1',
'line': {'color': 'yellow',
'dash': line[0]}})
# Plot the graph.
layout = go.Layout(
title='Production meterage of Machine1/Machine2/Machine3 for Quality A',
template='plotly_dark',
xaxis=dict(
autorange=True
),
yaxis=dict(
autorange=True
)
)
fig = go.Figure(data=t, layout=layout)
iplot(fig)
我得到的图表:
我为所有三台机器创建了一个折线图。但是折线图看起来很乱。需要做平滑处理。我尝试使用 gaussian_filter1d。但它对我不起作用。
【问题讨论】:
-
你想画什么?向我们展示您的尝试。
-
我想这会回答你的问题:stackoverflow.com/questions/40085300/…。当我在谷歌上搜索“熊猫情节平滑线”时,这是第一次点击。
标签: python pandas dataframe linechart smoothing