示例#1
0
 def test_to_pandas_density(self):
     """Should create a pandas dataframe of a denisty plot of the histogram"""
     hist = Histogram(bins=2)
     test_df = self.create_test_df()
     column_to_ad = test_df.select(F.col('value'))
     column_to_ad_2 = test_df.select(F.col('value2'))
     hist.add_column(column_to_ad)
     hist.add_column(column_to_ad_2)
     expected_df = pd.DataFrame({
         'value': [1.0, 0.5],
         'value2': [0.5, 1.0]
     }).set_index([[1.75, 3.25]])
     self.assertTrue(expected_df.equals(hist.to_pandas('density')))
示例#2
0
 def test_to_pandas_default(self):
     """Should create a pandas dataframe from the Histogram object"""
     hist = Histogram(bins=2)
     test_df = self.create_test_df()
     column_to_ad = test_df.select(F.col('value'))
     column_to_ad_2 = test_df.select(F.col('value2'))
     hist.add_column(column_to_ad)
     hist.add_column(column_to_ad_2)
     expected_df = pd.DataFrame({
         'value': [2, 1],
         'value2': [1, 2]
     }).set_index([['1.00 - 2.50', '2.50 - 4.00']])
     self.assertTrue(expected_df.equals(hist.to_pandas()))