PROBLEM @ Capstone Project: Netflix Data

Hello everybody,

I just started realizing my “Capstone Project: Netflix Data” (CODECADEMY-Capstone-Project-Netflix-Data/main.py at main · jonasbauer192/CODECADEMY-Capstone-Project-Netflix-Data · GitHub). Unfortunatelly, I did not get very far, because I received the following error message when I wanted to create the violine plot:

Traceback (most recent call last):
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\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\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\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py”, line 18, in execfile
exec(compile(contents+"\n", file, ‘exec’), glob, loc)
File “D:/CODECADEMY-Capstone-Project-Netflix-Data/Code/main.py”, line 25, in
sns.violinplot(data = netflix_stocks_quarterly, x = “Quarter”, y = “Price”)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\seaborn_decorators.py”, line 46, in inner_f
return f(**kwargs)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\seaborn\categorical.py”, line 2408, in violinplot
plotter.plot(ax)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\seaborn\categorical.py”, line 1043, in plot
self.draw_violins(ax)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\seaborn\categorical.py”, line 801, in draw_violins
self.draw_box_lines(ax, violin_data, support, density, i)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\seaborn\categorical.py”, line 967, in draw_box_lines
ax.scatter(center, q50,
File "D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib_init
.py", line 1412, in inner
return func(ax, *map(sanitize_sequence, args), kwargs)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\axes_axes.py”, line 4487, in scatter
self.add_collection(collection)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\axes_base.py”, line 2242, in add_collection
self._unstale_viewLim()
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\axes_base.py”, line 776, in _unstale_viewLim
self.autoscale_view(
{f"scale{name}": scale
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\axes_base.py”, line 2932, in autoscale_view
handle_single_axis(
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\axes_base.py”, line 2895, in handle_single_axis
x0, x1 = locator.nonsingular(x0, x1)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\ticker.py”, line 1654, in nonsingular
return mtransforms.nonsingular(v0, v1, expander=.05)
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\venv\lib\site-packages\matplotlib\transforms.py”, line 2880, in nonsingular
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
File “D:\CODECADEMY-Capstone-Project-Netflix-Data\Code\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.

So far, I updated all packages to the most acual release, which did not help. Even google could not help me out. :-/ I also tried to change the dtypes of the data series with the pd.to_numeric() command etc. In case if relevant: I am uing the IDE PyCharm.

I would really appreciate any advice since I have no clue what to do else.
Kind regards and thanks in advance,
Jonas

The notebook only has 38 lines of code. Is that all?

In your notebook after importing the csv files can you print out the first 5 rows and do a df.info() so we can see the data and the dtypes? (basically need to see more code to figure out the errors).

Hallo :slight_smile:

the .head() and .info method returns the following applied to each of the three data frames:

Date Open High … Close Price Volume
0 2017-01-01 124.959999 143.460007 … 140.710007 140.710007 181772200
1 2017-02-01 141.199997 145.949997 … 142.130005 142.130005 91432000
2 2017-03-01 142.839996 148.289993 … 147.809998 147.809998 110692700
3 2017-04-01 146.699997 153.520004 … 152.199997 152.199997 149769200
4 2017-05-01 151.910004 164.750000 … 163.070007 163.070007 116795800
[5 rows x 7 columns]
<bound method DataFrame.info of Date Open High … Close Price Volume
0 2017-01-01 124.959999 143.460007 … 140.710007 140.710007 181772200
1 2017-02-01 141.199997 145.949997 … 142.130005 142.130005 91432000
2 2017-03-01 142.839996 148.289993 … 147.809998 147.809998 110692700
3 2017-04-01 146.699997 153.520004 … 152.199997 152.199997 149769200
4 2017-05-01 151.910004 164.750000 … 163.070007 163.070007 116795800
5 2017-06-01 163.520004 166.869995 … 149.410004 149.410004 135675800
6 2017-07-01 149.800003 191.500000 … 181.660004 181.660004 185144700
7 2017-08-01 182.490005 184.619995 … 174.710007 174.710007 136523100
8 2017-09-01 175.550003 189.949997 … 181.350006 181.350006 111427900
9 2017-10-01 182.110001 204.380005 … 196.429993 196.429993 208657800
10 2017-11-01 197.240005 202.479996 … 195.509995 195.509995 161719700
11 2017-12-01 186.990005 194.490005 … 191.960007 191.960007 115103700
[12 rows x 7 columns]>
Date Open … Price Volume
0 2017-01-01 19872.859375 … 19864.089844 6482450000
1 2017-02-01 19923.810547 … 20812.240234 6185580000
2 2017-03-01 20957.289063 … 20663.220703 6941970000
3 2017-04-01 20665.169922 … 20940.509766 5392630000
4 2017-05-01 20962.730469 … 21008.650391 6613570000
[5 rows x 7 columns]
<bound method DataFrame.info of Date Open … Price Volume
0 2017-01-01 19872.859375 … 19864.089844 6482450000
1 2017-02-01 19923.810547 … 20812.240234 6185580000
2 2017-03-01 20957.289063 … 20663.220703 6941970000
3 2017-04-01 20665.169922 … 20940.509766 5392630000
4 2017-05-01 20962.730469 … 21008.650391 6613570000
5 2017-06-01 21030.550781 … 21349.630859 7214590000
6 2017-07-01 21392.300781 … 21891.119141 5569720000
7 2017-08-01 21961.419922 … 21948.099609 6150060000
8 2017-09-01 21981.769531 … 22405.089844 6342130000
9 2017-10-01 22423.470703 … 23377.240234 7302910000
10 2017-11-01 23442.900391 … 24272.349609 7335640000
11 2017-12-01 24305.400391 … 24719.220703 6589890000
[12 rows x 7 columns]>
Date Open High … Price Volume Quarter
0 2017-01-03 124.959999 128.190002 … 127.489998 9437900 Q1
1 2017-01-04 127.489998 130.169998 … 129.410004 7843600 Q1
2 2017-01-05 129.220001 132.750000 … 131.809998 10185500 Q1
3 2017-01-06 132.080002 133.880005 … 131.070007 10657900 Q1
4 2017-01-09 131.479996 131.990005 … 130.949997 5766900 Q1
[5 rows x 8 columns]
<bound method DataFrame.info of Date Open High … Price Volume Quarter
0 2017-01-03 124.959999 128.190002 … 127.489998 9437900 Q1
1 2017-01-04 127.489998 130.169998 … 129.410004 7843600 Q1
2 2017-01-05 129.220001 132.750000 … 131.809998 10185500 Q1
3 2017-01-06 132.080002 133.880005 … 131.070007 10657900 Q1
4 2017-01-09 131.479996 131.990005 … 130.949997 5766900 Q1
… … … … … … … …
246 2017-12-22 188.330002 190.949997 … 189.940002 3878900 Q4
247 2017-12-26 189.779999 189.940002 … 187.759995 3045700 Q4
248 2017-12-27 187.800003 188.100006 … 186.240005 4002100 Q4
249 2017-12-28 187.179993 194.490005 … 192.710007 10107400 Q4
250 2017-12-29 192.509995 193.949997 … 191.960007 5187600 Q4
[251 rows x 8 columns]>
Backend TkAgg is interactive backend. Turning interactive mode on.

I hope these information are meaningful enough to find a solution.

Kind regards,
Jonas

I meant when you push your jupyter notebook to GH, (or Colab if you used that) the file is truncated. is main.py your code for the project?

Yes, the file I used for the project is “main.py”. Unfortunatelly, I use PyCharm instead of jupyter notebook

Okay, when you created the violinplot did you create the ax = sns.violinplot(...) variable?
All I see is:

sns.violinplot(data = netflix_stocks_quarterly, x = "Quarter", y = "Price")
plt.show()

Should be something like:

sns.set_style("darkgrid")
sns.set_palette("bright")
ax = sns.violinplot(x="Quarter", y="Price", data= netflix_quart)
ax.set_title("Distribution of 2017 Netflix Stock Prices by Quarter", fontsize=14)
ax.set_xlabel("Business Quarters in 2017")
ax.set_ylabel("Closing Stock Price")

plt.show()

Also, a somewhat easier (IMO) notebook to use is Google Colab. It’s an app that you can add to your GDrive and then create notebooks and push them to a GH repo. You can also upload csv files (25mb and under) to the same repo. From there, it’s easier to import csv files to a notebook. Once the csv has been uploaded to GitHub, view it in “raw” then grab the URL. When you’re in the notebook and import the file, you can just use that URL. Like so:

netflix_quart = pd.read_csv("https://raw.githubusercontent.com/yourGHProfileandrepopathhereNFLX_daily_by_quarter.csv")
netflix_quart.head()

I also tried it they way requiremed in the assignments. But since it leads to the same error message I tried to reduce the code to the “relevant” lines.

I’m not sure what you mean by “tried to reduce the code to the relevant lines”. Did you drop rows from the dataframe?

means that when iterating through the list, “None” isn’t an object type that can be called.
https://www.techgeekbuzz.com/python-typeerror-nonetype-object-is-not-callable-solution/

I dropped some lines of the plot commands such as .set_style, set_title, etc. I did not drop any row from the data frame. In PyCharm, the data frame “netflix_stocks_quarterly” looks like the uploaded screenshot.

Since the dtype command tells me that

Price float64
Quarter object

applies, I cannot relate it to the NoneType-Error message.

UPDATE:
I just copied the code and pasted it into a jupyter notebook and it worked. But I still cannot understand why there is an error message only using PyCharm.

1 Like

I think it has to do with how you installed Seaborn and Matplotlib into PyCharm.
Admittedly, I don’t know PyCharm and have never used it.

Okay, but thanks for your time. If I can figure the reason out I will post it here.

1 Like