AttributeError Traceback (most recent call last)
Cell In[49], line 3
1 # Create a horizontal bar plot where the y-axis represents the label and the x-axis represents the number of images with that label
2 plt.figure(figsize=(8, 12))
----> 3 sns.countplot(x='Number of images', data=df, order=df_train['label'].value_counts().index)
4 plt.xlabel('Number of images')
5 plt.ylabel('Label')
File ~/cluster-env/trident_env/lib/python3.10/site-packages/seaborn/categorical.py:2943, in countplot(data, x, y, hue, order, hue_order, orient, color, palette, saturation, width, dodge, ax, **kwargs)
2940 elif x is not None and y is not None:
2941 raise ValueError("Cannot pass values for both x and y")
-> 2943 plotter = _CountPlotter(
2944 x, y, hue, data, order, hue_order,
2945 estimator, errorbar, n_boot, units, seed,
2946 orient, color, palette, saturation,
2947 width, errcolor, errwidth, capsize, dodge
2948 )
2950 plotter.value_label = "count"
2952 if ax is None:
File ~/cluster-env/trident_env/lib/python3.10/site-packages/seaborn/categorical.py:532, in _CategoricalPlotter.establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
524 # Option 2:
525 # We are plotting a long-form dataset
526 # -----------------------------------
(...)
529
530 # See if we need to get variables from data
531 if data is not None:
--> 532 x = data.get(x, x)
533 y = data.get(y, y)
534 hue = data.get(hue, hue)
File /opt/spark/python/lib/pyspark.zip/pyspark/sql/dataframe.py:1988, in DataFrame.getattr(self, name)
1978 """Returns the :class:Column denoted by name.
1979
1980 .. versionadded:: 1.3.0
(...)
1985 [Row(age=2), Row(age=5)]
1986 """
1987 if name not in self.columns:
-> 1988 raise AttributeError(
1989 "'%s' object has no attribute '%s'" % (self.class.name, name)
1990 )
1991 jc = self._jdf.apply(name)
1992 return Column(jc)
AttributeError: 'DataFrame' object has no attribute 'get'
In Analyzing Snapshot Serengeti data with Microsoft Fabric. I got an error message:
AttributeError Traceback (most recent call last) Cell In[49], line 3 1 # Create a horizontal bar plot where the y-axis represents the label and the x-axis represents the number of images with that label 2 plt.figure(figsize=(8, 12)) ----> 3 sns.countplot(x='Number of images', data=df, order=df_train['label'].value_counts().index) 4 plt.xlabel('Number of images') 5 plt.ylabel('Label')
File ~/cluster-env/trident_env/lib/python3.10/site-packages/seaborn/categorical.py:2943, in countplot(data, x, y, hue, order, hue_order, orient, color, palette, saturation, width, dodge, ax, **kwargs) 2940 elif x is not None and y is not None: 2941 raise ValueError("Cannot pass values for both
x
andy
") -> 2943 plotter = _CountPlotter( 2944 x, y, hue, data, order, hue_order, 2945 estimator, errorbar, n_boot, units, seed, 2946 orient, color, palette, saturation, 2947 width, errcolor, errwidth, capsize, dodge 2948 ) 2950 plotter.value_label = "count" 2952 if ax is None:File ~/cluster-env/trident_env/lib/python3.10/site-packages/seaborn/categorical.py:1530, in _BarPlotter.init(self, x, y, hue, data, order, hue_order, estimator, errorbar, n_boot, units, seed, orient, color, palette, saturation, width, errcolor, errwidth, capsize, dodge) 1525 def init(self, x, y, hue, data, order, hue_order, 1526 estimator, errorbar, n_boot, units, seed, 1527 orient, color, palette, saturation, width, 1528 errcolor, errwidth, capsize, dodge): 1529 """Initialize the plotter.""" -> 1530 self.establish_variables(x, y, hue, data, orient, 1531 order, hue_order, units) 1532 self.establish_colors(color, palette, saturation) 1533 self.estimate_statistic(estimator, errorbar, n_boot, seed)
File ~/cluster-env/trident_env/lib/python3.10/site-packages/seaborn/categorical.py:532, in _CategoricalPlotter.establish_variables(self, x, y, hue, data, orient, order, hue_order, units) 524 # Option 2: 525 # We are plotting a long-form dataset 526 # ----------------------------------- (...) 529 530 # See if we need to get variables from
data
531 if data is not None: --> 532 x = data.get(x, x) 533 y = data.get(y, y) 534 hue = data.get(hue, hue)File /opt/spark/python/lib/pyspark.zip/pyspark/sql/dataframe.py:1988, in DataFrame.getattr(self, name) 1978 """Returns the :class:
Column
denoted byname
. 1979 1980 .. versionadded:: 1.3.0 (...) 1985 [Row(age=2), Row(age=5)] 1986 """ 1987 if name not in self.columns: -> 1988 raise AttributeError( 1989 "'%s' object has no attribute '%s'" % (self.class.name, name) 1990 ) 1991 jc = self._jdf.apply(name) 1992 return Column(jc)AttributeError: 'DataFrame' object has no attribute 'get'