我想在网页上显示pandas df.plot.bar()的结果。我该怎么办? 这就是我想要的。
public class ProjectStructure
{
public CustomerInfo CustomerInformation { get; set; }
public int JobInformationID { get; set; }
}
public class CustomerInfo
{
public DateTime PreferredMeasureTime { get; set; }
public DateTime DueDate { get; set; }
public ContactDetail ContactDetails { get; set; }
}
public class ContactDetail
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string UnitNo { get; set; }
public string StreetNo { get; set; }
}
public class job
{
public int jobID { get; set; }
public virtual ICollection<address> addresses { get; set; }
}
public partial class address
{
public long id { get; set; }
public string unitNumber { get; set; }
public string streetNumber { get; set; }
}}
答案 0 :(得分:0)
这解决了我的问题
from django.views.generic import View
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from django.http import HttpResponse
import pandas as pd
import seaborn
def graph(request):
fig = Figure()
fig.set_size_inches(15, 6, forward=True)
ax = fig.add_subplot(111)
fig.subplots_adjust(bottom=0.35)
final_itemset = pd.Series.from_csv("C:/Users/abc/final_two_itemset.csv")
final_itemset.plot.bar(ax=ax)
canvas = FigureCanvas(fig)
response = HttpResponse( content_type = 'image/png')
canvas.print_png(response)
return response