I am currently using Python with the IDE PyCharm to plot a data frame generated in pandas with seaborn. I am appliing the following code:
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
netflix_stocks = pd.read_csv("NFLX.csv")
dowjones_stocks = pd.read_csv("DJI.csv")
netflix_stocks_quarterly = pd.read_csv("NFLX_daily_by_quarter.csv")
# rename columns
netflix_stocks.rename(columns = {'Adj Close': 'Price'}, inplace = True)
dowjones_stocks.rename(columns = {'Adj Close': 'Price'}, inplace = True)
netflix_stocks_quarterly.rename(columns = {'Adj Close': 'Price'}, inplace = True)
# visualizing the netflix quarterly data
ax = plt.subplot()
sns.violinplot(data = netflix_stocks_quarterly, x = "Quarter", y = "Price")
ax.set_title("Distribution of 2017 Netflix Stock Prices by Quarter")
plt.xlabel("Business Quarters in 2017")
plt.ylabel("Closing Stock Price")
plt.savefig("Distribution of 2017 Netflix Stock Prices by Quarter.png")
plt.show()
which leads me to the error message
Traceback (most recent call last):
File "D:\testproject\venv\lib\site-packages\numpy\core\getlimits.py", line 459, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Program Files (x86)\PyCharm Community Edition 2021.3.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\Program Files (x86)\PyCharm Community Edition 2021.3.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/testproject/main.py", line 18, in <module>
sns.violinplot(data = netflix_stocks_quarterly, x = "Quarter", y = "Price")
File "D:\testproject\venv\lib\site-packages\seaborn\_decorators.py", line 46, in inner_f
return f(**kwargs)
File "D:\testproject\venv\lib\site-packages\seaborn\categorical.py", line 2408, in violinplot
plotter.plot(ax)
File "D:\testproject\venv\lib\site-packages\seaborn\categorical.py", line 1043, in plot
self.draw_violins(ax)
File "D:\testproject\venv\lib\site-packages\seaborn\categorical.py", line 801, in draw_violins
self.draw_box_lines(ax, violin_data, support, density, i)
File "D:\testproject\venv\lib\site-packages\seaborn\categorical.py", line 967, in draw_box_lines
ax.scatter(center, q50,
File "D:\testproject\venv\lib\site-packages\matplotlib\__init__.py", line 1412, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "D:\testproject\venv\lib\site-packages\matplotlib\axes\_axes.py", line 4487, in scatter
self.add_collection(collection)
File "D:\testproject\venv\lib\site-packages\matplotlib\axes\_base.py", line 2242, in add_collection
self._unstale_viewLim()
File "D:\testproject\venv\lib\site-packages\matplotlib\axes\_base.py", line 776, in _unstale_viewLim
self.autoscale_view(**{f"scale{name}": scale
File "D:\testproject\venv\lib\site-packages\matplotlib\axes\_base.py", line 2932, in autoscale_view
handle_single_axis(
File "D:\testproject\venv\lib\site-packages\matplotlib\axes\_base.py", line 2895, in handle_single_axis
x0, x1 = locator.nonsingular(x0, x1)
File "D:\testproject\venv\lib\site-packages\matplotlib\ticker.py", line 1654, in nonsingular
return mtransforms.nonsingular(v0, v1, expander=.05)
File "D:\testproject\venv\lib\site-packages\matplotlib\transforms.py", line 2880, in nonsingular
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
File "D:\testproject\venv\lib\site-packages\numpy\core\getlimits.py", line 462, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
python-BaseException
Backend TkAgg is interactive backend. Turning interactive mode on.
For some reason, the same code works under jupyter notebook. I am importing pandas, matplotlib and seaborn in the following versions:
Further, I created a project using a virtual environment as follows:
project creation with a virtual environment
Since the dataframes have no "empty" entries or those, for which the data type must be changed I cannot figure the reason out. The dataframe, which should be plotted looks like:
I appreciate any advice!
Thanks in advance, Jonas