Histograms

Draw one histogram of the DataFrame’s columns, or single histogram for Series

A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins

Examples

Histogram of a Column in a DataFrame

In the example below, we make an histogram from the Age column in the titanic dataset.

import { useEffect } from 'react';
import './App.css';
import { readCSV } from "danfojs-nightly";

function App() {

  useEffect(() => {
    readCSV("https://raw.githubusercontent.com/pandas-dev/pandas/master/doc/data/titanic.csv")
      .then(df => {

        df['Age'].plot("plot_div").hist()

      }).catch(err => {
        console.log(err);
      })
  }, [])

  return (
    <div className="App">
      <header className="App-header">
        <div id="plot_div"></div>
      </header>
    </div>
  );
}

export default App;

Customized Histogram plots on DataFrame

import { useEffect } from 'react';
import './App.css';
import { readCSV } from "danfojs-nightly";

function App() {

  useEffect(() => {
    readCSV("https://raw.githubusercontent.com/pandas-dev/pandas/master/doc/data/titanic.csv")
      .then(df => {

        const layout = {
          bargap: 0,
          bargroupgap: 0.1,
          title: "Histogram of two columns stacked",
          xaxis: { title: "Value" },
          yaxis: { title: "Count" }
        }

        const sub_df = df.loc({ columns: ["Fare", "Age"] })
        sub_df.plot("plot_div").hist({ layout })

      }).catch(err => {
        console.log(err);
      })
  }, [])

  return (
    <div className="App">
      <header className="App-header">
        <div id="plot_div"></div>
      </header>
    </div>
  );
}

export default App;
a

For more configuration options for Histograms, see the Plotly doc.

Last updated