熊猫不密谋

时间:2019-06-19 18:48:06

标签: python python-3.x spyder

无法绘制

byDate = df.groupby(['Date'],axis = 0).count()
byDate['lat'].plot

我已经尝试使用plt.show()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from plotly import __version__
import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode,plot,iplot
import plotly.graph_objs as go

df = pd.read_csv('911.csv')
df.set_index('twp')
df['reason'] = df['title'].str.split(':').str.get(0)
df['timeStamp'] = pd.to_datetime(df['timeStamp'])
df['Hour'] = df['timeStamp'].dt.hour
df['Month'] = df['timeStamp'].dt.month
df['Day of Week'] = df['timeStamp'].dt.weekday_name
df['Date'] = df['timeStamp'].dt.to_period('M')

byDate = df.groupby(['Date'],axis = 0).count()
byDate['lat'].plot

byDate = df.groupby(['Date'],axis = 0).count()

Out[50]: pandas.plotting._core.SeriesPlotMethods object at 0x000001DB6105C400

该图的样本数据

Date        lat 
2015-12-10  114 
2015-12-11  391 
2015-12-12  402 
2015-12-13  316 
2015-12-14  444 
2015-12-15  419 
2015-12-16  376 
2015-12-17  387

1 个答案:

答案 0 :(得分:0)

像评论Hoog一样,.plot部分需要像“ .plot()”这样的括号