Hello Team,
I have a csv file, I will read the data from the file and will show the data in the form of a graph (Dataframe). I can able to bring the data in the form of table and I have also constructed the chart with X and Y axis metrics.
My problem is I have different device names in a column and I would like to construct the graph based on that, I have implemented the below code and also attached my output images. I still could not achieve the result.
def DropdownDevices():
devicename = pd.read_csv("deviceinfo.csv", header=0, sep=",", names=["DDID", "TrendInfo_MaxValue", "TrendInfo_MinValue", "TrendInfo_PointValue", "TrendInfo_PollDateTime", "RegionName", "SiteName", "SuiteName", "DeviceName", "DeviceType", "FunctionName"], error_bad_lines=False,index_col=False, dtype='unicode')
devicename["TrendInfo_PollDateTime"] = pd.to_datetime(devicename["TrendInfo_PollDateTime"])
return devicename.set_index("DDID")
deviceList = DropdownDevices()
devices = st.multiselect(
"Choose devices", list(deviceList.index), ["1743766", "1743856", "1744294"]
)
if not devices:
st.error("Please select at least one device.")
result = deviceList.loc[devices]
st.write("### Device Details", result)
chart = (
alt.Chart(result)
.mark_area(opacity=0.3)
.encode(
x="TrendInfo_PollDateTime:T",
y=alt.Y("TrendInfo_MinValue:Q", stack=None),
color="Devices:N",
)
)
st.altair_chart(chart, use_container_width=True)
Kindly suggest me a solution on this.
Thanks and Regards,
S.Thilak