Why isn't this code to plot a histogram on a continuous value Pandas column working?

前端 未结 2 651
余生分开走
余生分开走 2021-02-01 15:10

I am trying to create a histogram on a continuous value column Trip_distance in a large 1.4M row pandas dataframe. Wrote the following code:

fig =          


        
2条回答
  •  Happy的楠姐
    2021-02-01 15:55

    Here's another way to plot the data, involves turning the date_time into an index, this might help you for future slicing

    #convert column to datetime
    trip_data['lpep_pickup_datetime'] = pd.to_datetime(trip_data['lpep_pickup_datetime'])
    #turn the datetime to an index
    trip_data.index = trip_data['lpep_pickup_datetime']
    #Plot
    trip_data['Trip_distance'].plot(kind='hist')
    plt.show()
    

提交回复
热议问题