Apr-22-2018, 02:11 PM
(This post was last modified: Apr-22-2018, 02:11 PM by niks250891.)
I succeed in plotting using below code :
1.When Time intervals are very close,Data overlaps on graph.Is there a way to overcome it.
2.When using large data set,graph us not getting plotted giving the error message :
ValueError: Index contains duplicate entries, cannot reshape.
To overcome the error 2,i tried some random integer adding to A column(date value but same error).All the time entries are unique in my data set but still giving the error.Any suggestions please.
import pandas as pd all_data = [('2018-04-09', '10:18:11', ['s1',10],['s2',15],['s3',5]), ('2018-04-09', '10:20:11', ['s4',8], ['s2',20],['s1',10]), ('2018-04-10', '10:30:11', ['s4',10],['s5',6], ['s6',3]) ] #load data into dataframe df = pd.DataFrame(all_data, columns = list("ABCDE")) #combine the two descriptors df["day/time"] = df["A"] + "\n" + df["B"] #assign each list to a new row with the appropriate day/time label df = df.melt(id_vars = ["day/time"], value_vars = ["C", "D", "E"]) #split each list into category and value df[["category", "val"]] = pd.DataFrame(df.value.values.tolist(), index = df.index) #create a table with category-value pairs from all lists, missing values are set to NaN df = df.pivot(index = "day/time", columns = "category", values = "val") #plot a stacked bar chart df.plot(kind = "bar", stacked = True) fig=df.iplot(kin='bar',barmode='stack',asFigure=True) plotly.offline.plt(fig,filename="stack1.html)However I faced two errors:
1.When Time intervals are very close,Data overlaps on graph.Is there a way to overcome it.
2.When using large data set,graph us not getting plotted giving the error message :
ValueError: Index contains duplicate entries, cannot reshape.
To overcome the error 2,i tried some random integer adding to A column(date value but same error).All the time entries are unique in my data set but still giving the error.Any suggestions please.