On 2021-11-21 16:39, Mahmood Naderan via Python-list wrote:
The best way to get
assistance here on the list is to create a minimal, self-contained,
run-able, example program that you can post in its entirety here that
demonstrates the issue.
I created a sample code with input. Since the code processes a csv file to
group input rows, I also included those in this minimal code but those
preprocesses are not buggy. In this sample code, I used print() to print
necessary information. The error exists in the plot function. I tested the
dictionary build before that and it is fine.
Code is available at https://pastebin.com/giAnjJDV and the input file
(test.batch.csv) is available https://pastebin.com/Hdp4Wt9B
The run command is "python3 test.py". With the versions specified in my system,
here is the full output:
$ python3 test.py
Reading file...
matplotlib version = 3.3.4
pandas version = 1.2.3
sys version sys.version_info(major=3, minor=8, micro=10, releaselevel='final',
serial=0)
Original dictionary = {'dummy': Value
M1 0
M2 0
M3 0, 'K1::foo(bar::z(x,u))': Value Value
0 10 2
1 5 2
2 10 2, 'K2::foo()': Value
0 20
1 10
2 15, 'K3::foo(baar::y(z,u))': Value
0 12
1 13
2 14, 'K3::foo(bar::y(z,u))': Value
0 6
1 7
2 8}
New dictionary for plot = {'dummy': Value
M1 0
M2 0
M3 0, 'K1::foo(bar::z(x,u))': Value Value
0 10 2
1 5 2
2 10 2, 'K3::foo(bar::y(z,u))': Value
0 6
1 7
2 8}
Key is K1::foo(bar::z(x,u)) -> df is Value Value
0 10 2
1 5 2
2 10 2
axes= [<AxesSubplot:> <AxesSubplot:>]
axes[0]= AxesSubplot(0.125,0.53;0.775x0.35)
cnt= 1
row= 1 10
2 2
Name: 0, dtype: int64
Traceback (most recent call last):
File "test.py", line 74, in <module>
plot_kernels(my_dict2)
File "test.py", line 52, in plot_kernels
plot_dataframe(df, cnt, axes)
File "test.py", line 36, in plot_dataframe
ax1 = row.plot(label=cnt, ax=axes[0], marker='o') # Line chart
File
"/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_core.py",
line 955, in __call__
return plot_backend.plot(data, kind=kind, **kwargs)
File
"/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/__init__.py",
line 61, in plot
plot_obj.generate()
File
"/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py",
line 283, in generate
self._adorn_subplots()
File
"/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py",
line 483, in _adorn_subplots
all_axes = self._get_subplots()
File
"/home/mahmood/.local/lib/python3.8/site-packages/pandas/plotting/_matplotlib/core.py",
line 903, in _get_subplots
ax for ax in self.axes[0].get_figure().get_axes() if isinstance(ax,
Subplot)
AttributeError: 'NoneType' object has no attribute 'get_axes'
I am pretty sure that there is a version mismatch because on a system with
Pandas 1.3.3 the output should be like https://imgur.com/a/LZ9eAzl
Any feedback is appreciated.
I installed the latest pandas, although on Python 3.10, and the script
worked without a problem.
--
https://mail.python.org/mailman/listinfo/python-list