Python 3.x 将csv数据加载到bokeh时出现问题

Python 3.x 将csv数据加载到bokeh时出现问题,python-3.x,csv,plot,bokeh,Python 3.x,Csv,Plot,Bokeh,我在从csv文件加载数据到bokeh时遇到问题,从bokeh数据库加载数据是可行的,但当我尝试从csv文件加载数据时,它并没有加载,所以我一直在阅读,但到目前为止运气不佳。 提前谢谢 df = pd.read_csv('unemployment1948.csv', delimiter = ',', index_col = 'Year') df = pd.DataFrame(df) df.head() output_notebook() group = df

我在从csv文件加载数据到bokeh时遇到问题,从bokeh数据库加载数据是可行的,但当我尝试从csv文件加载数据时,它并没有加载,所以我一直在阅读,但到目前为止运气不佳。 提前谢谢

df = pd.read_csv('unemployment1948.csv', delimiter = ',', index_col = 
                 'Year')
df = pd.DataFrame(df)
df.head()


output_notebook()
group = df[35:].groupby('Year')
source = ColumnDataSource(df)
group.describe()
df.columns
#source = ColumnDataSource(df(x=df.loc[15:40].index, 
#                              y=df.loc[15:40].Annual))

p = figure(plot_height=300, plot_width=900, x_range=group, 
           title='Umployment over the years',
           x_axis_label='Year', y_axis_label='Annual')

p.circle(x=index, y='Annual', width=0.9, color ='#35B778' , source=source)
show(p)

您的
df
已经是一个
DataFrame
。试试这个:

import os
import pandas as pd
from bokeh.io import show
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

df = pd.read_csv(os.path.join(os.path.dirname(__file__), "unemployment1948.csv",))
output_notebook()
source = ColumnDataSource(df)

p = figure(plot_height = 300, plot_width = 900,
           title = 'Umployment over the years',
           x_axis_label = 'Year', y_axis_label = 'Annual')

p.circle(x = 'Year', y = 'Annual', line_width = 0.9, color = '#35B778' , source = source)
show(p)

您的
df
已经是一个
数据帧
。试试这个:

import os
import pandas as pd
from bokeh.io import show
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

df = pd.read_csv(os.path.join(os.path.dirname(__file__), "unemployment1948.csv",))
output_notebook()
source = ColumnDataSource(df)

p = figure(plot_height = 300, plot_width = 900,
           title = 'Umployment over the years',
           x_axis_label = 'Year', y_axis_label = 'Annual')

p.circle(x = 'Year', y = 'Annual', line_width = 0.9, color = '#35B778' , source = source)
show(p)

我学习了如何处理DataFrame和ColumnDateSource,因此您可以轻松地操作数据,而不需要使用操作系统模块。 谢谢你的帮助

import csv
#import re
import pandas as pd
import numpy as np
#import random
##from collections import Counter, defaultdict
#import random

dfU = pd.read_csv('unemployment1948.csv')
dfU = pd.DataFrame(dfU)
dfU.index
y = dfU.iloc[35:].Year
x = dfU.iloc[35:].Annual
#xRange = dfU.iloc[35:]
source = ColumnDataSource(dfU)

output_notebook()
p = figure(plot_height=300, plot_width=800, title='Unemployment over the years')
p.vbar(x='Year', top='Annual', width=0.9, color ='#35B778' , source=source)
show(p)

我学习了如何处理DataFrame和ColumnDateSource,因此您可以轻松地操作数据,而不需要使用操作系统模块。 谢谢你的帮助

import csv
#import re
import pandas as pd
import numpy as np
#import random
##from collections import Counter, defaultdict
#import random

dfU = pd.read_csv('unemployment1948.csv')
dfU = pd.DataFrame(dfU)
dfU.index
y = dfU.iloc[35:].Year
x = dfU.iloc[35:].Annual
#xRange = dfU.iloc[35:]
source = ColumnDataSource(dfU)

output_notebook()
p = figure(plot_height=300, plot_width=800, title='Unemployment over the years')
p.vbar(x='Year', top='Annual', width=0.9, color ='#35B778' , source=source)
show(p)