![]() ![]() # Rename 'high' column to 'high_goog' and 'high_apple'ĭf_goog.rename(columns=, inplace=True)ĭf_merged = pd.merge(df_goog, df_apple, how='inner', on='date') # Select only 'date' and 'high' columns for Google and Apple You can learn more about correlation here. In this example, we want to see the correlation between Google's stock prices and Apple's stock prices. In this section, we use the open-source S&P 500 stock data available on Kaggle. Creating a scatter plot from Pandas dataframe Additionally, the line function (glyph in Bokeh) is used to generate a time series plot for Google's high prices. In the chart, it was necessary to convert the date column to datetime to render dates along the x-axis. Plot = figure(title= "Pandas Line Plot", x_axis_type = 'datetime', x_axis_label = 'date', y_axis_label= 'Prices') # Import packagesĭf_goog = pd.to_datetime(df_goog) First, we load the data using Pandas and then check the first five rows of the Pandas dataframe. We want to see the trend for Google’s stock over the five-year period. Volume - volume of stocks traded in the day.Close - stock’s closing price for the day.High - stock’s highest price in the day.Date - day of the week date in format yy-mm-dd.The dataset contains all the stocks contained in the S&P 500 index for five years up to December 2018. The data in this example is obtained from Kaggle. This yields the following graph: Creating Plots Using Pandas Dataframes Plotting lines with Pandas dataframes Plot.circle(x_arr,y_arr, size = 30, alpha = 0.5) Plot = figure(title = "Scatter plot", x_axis_label = "Label name of x axis", y_axis_label ="Label name of y axis") Bokeh Plots from NumPy Arrays Creating line plots from NumPy arrays # Import packagesĬreating scatter plots from NumPy arrays # Import packages ![]() The ColumnDataSource is the essence of Bokeh, making it possible to share data over multiple plots and widgets. In this tutorial, you will learn how to plot data with NumPy arrays, dataframes in Pandas, and ColumnDataSource using Bokeh. Now, you can extend this concept and build plots from different data structures such as arrays and dataframes. In our first Data Visualization with Bokeh tutorial, you learned how to build visualizations from scratch using glyphs. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |