Home>

I am studying with python and machine learning beginners.

I want to create a boxplot with seaborn for a csv file read with pandas.
Kaggle's Bike Sharing Demand problem is being tested with the source code posted in Kernels "EDA&Ensemble Model (Top 10 Percentile)"

I want to extract one or two data from a data frame column and create a boxplot.

Error message
import numpy as np
import pandas as pd
import seaborn as sn
import matplotlib.pyplot as plt
bike = pd.read_csv (BikeSharingDataset.csv ")


I am trying to create a boxplot with seaborn boxplot.
TypeError:'tuple'object is not callable
Is displayed and the graph cannot be displayed. What should I do now….
Thanks for your patience.

Applicable source code
fig, axes = plt.subplots (nrows = 2, ncols = 2)
fig.set_size_inches = (12,10)

sn.boxplot (data = bike, y = "cnt", orient = "v", ax = axes [0] [0])
sn.boxplot (data = bike, y = "cnt", x = "season", orient = "v", ax = axes [0] [1])
sn.boxplot (data = bike, y = "cnt", x = "hr", orient = "v", ax = axes [1] [0])
sn.boxplot (data = bike, y = "cnt", x = "weekday", orient = "v", ax = axes [1] [1])

axes [0] [0] .set (ylabel = 'Count', title = "Box Plot On Count")
axes [0] [1] .set (xlabel = 'Season', ylabel = 'Count', title = "Box Plot On Count Across Season")
axes [1] [0] .set (xlabel = 'Hour Of The Day', ylabel = 'Count', title = "Box Plot On Count Across Hour Of The Day")
axes [1] [1] .set (xlabel = 'Working Day', ylabel = 'Count', title = "Box Plot On Count Across Working Day")
------------------------------------- --------------------------------------
TypeError Traceback (most recent call last)
~ \ Anaconda3 \ lib \ site-packages \ IPython \ core \ formatters.py in __call __ (self, obj)
    339 pass
    340 else:
->341 return printer (obj)
    342 # Finally look for special method names
    343 method = get_real_method (obj, self.print_method)
~ \ Anaconda3 \ lib \ site-packages \ IPython \ core \ pylabtools.py in<lambda>(fig)
    239
    240 if 'png' in formats:
->241 png_formatter.for_type (Figure, lambda fig: print_figure (fig, 'png', ** kwargs))
    242 if 'retina' in formats or 'png2x' in formats:
    243 png_formatter.for_type (Figure, lambda fig: retina_figure (fig, ** kwargs))
~ \ Anaconda3 \ lib \ site-packages \ IPython \ core \ pylabtools.py in print_figure (fig, fmt, bbox_inches, ** kwargs)
    one two Three 
    124 bytes_io = BytesIO ()
->125 fig.canvas.print_figure (bytes_io, ** kw)
    126 data = bytes_io.getvalue ()
    127 if fmt == 'svg':
~ \ Anaconda3 \ lib \ site-packages \ matplotlib \ backend_bases.py in print_figure (self, filename, dpi, facecolor, edgecolor, orientation, format, ** kwargs)
   2189 origedgecolor = self.figure.get_edgecolor ()
   2190
->2191 self.figure.dpi = dpi
   2192 self.figure.set_facecolor (facecolor)
   2193 self.figure.set_edgecolor (edgecolor)
~ \ Anaconda3 \ lib \ site-packages \ matplotlib \ figure.py in _set_dpi (self, dpi, forward)
    480 self.dpi_scale_trans.clear (). Scale (dpi, dpi)
    481 w, h = self.get_size_inches ()
->482 self.set_size_inches (w, h, forward = forward)
    483 self.callbacks.process ('dpi_changed', self)
    484
TypeError: 'tuple' object is not callable
<Figure size 432x288 with 4 Axes>
Tried
sn.boxplot (y = bike ["cnt"], orient = "v", ax = axes [0] [0])
sn.boxplot (y = bike ["cnt"], x = bike ["season"], orient = "v", ax = axes [0] [1])
sn.boxplot (y = bike ["cnt"], x = bike ["hr"], orient = "v", ax = axes [1] [0])
sn.boxplot (y = bike ["cnt"], x = bike ["weekday"], orient = "v", ax = axes [1] [1])


I tried, but I get the same error code.

Supplemental information (FW/tool version etc.)

JupyterNotebook
Windows 7 professional

  • Answer # 1

    fig.set_size_inches = (12,10)isn't different. Since it is a method, I have to callfig.set_size_inches (12,10).

    As a result of overwriting a

    method withtuple, when the method is called,TypeError:'tuple'object is not callablethink.