根据另一列的条件值绘制一列的值?

时间:2019-05-02 05:50:01

标签: python-3.x pandas dataframe data-science

我的df看起来像这样,

Sub test3()
    Dim macRange As Range, macCell As Range, dic As Object
    Set dic = CreateObject("Scripting.Dictionary")
    dic.comparemode = vbTextCompare 'use in case when you need to remove case sensitivity for dictionary
    dic.Add "SEP", ""
    dic.Add "SIP", ""
    dic.Add "", ""
    Set macRange = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
    For Each macCell In macRange
        If Not dic.exists(Left(macCell.Value, 3)) Then macCell.Interior.ColorIndex = 6
    Next macCell
End Sub

我想调用或标绘开始时间为任何特定时间或例如 2019-04-01 15:30:00 的所有成绩,并标绘或调用所有该开始时间的成绩下的值,我该怎么做?

我尝试了类似id | Start_time | Grades swe 2019-04-01 15:30:00 0.54 few 2019-04-01 15:30:00 0.43 yre 2019-04-01 15:00:00 0.98

的操作

但似乎不起作用

谢谢

1 个答案:

答案 0 :(得分:1)

IIUC,您想过滤特定日期的数据并绘制成绩列。

d = df.loc[df["Start_time"] == "2019-04-01 15:30:00"]
d['Grades'].plot.bar() # or just plot() if a line graph

请注意,这将按原样绘制Grades值-因为您没有提到X轴。

编辑:

一个班轮:

df.loc[df["Start_time"] == "2019-04-01 15:30:00"]['Grades'].plot.bar()