Pandas .plot() call freezing GUI - user-interface

I'm attempting to create graphs using pandas on Python 2.7 OSX 10.
import numpy as np
import pandas as pd
import Quandl
pd.options.display.mpl_style = 'default'
TOKEN = 'tWquoUMLCebqSBMbTFNg'
print 'Pandas Version', pd.__version__
print 'Numpy version', np.__version__
uk_df = Quandl.get('OECD/HEALTH_STAT_CICDHOCD_TXCMILTX_GBR', authtoken=TOKEN)
print uk_df.head(8)
uk_df.plot()
Output:
Pandas Version 0.12.0
Numpy version 1.8.0
…and then some data. The Python GUI spaceship attempts to open, but bounces forever. What am I missing here?
I have the latest matplotlib installed as well.

Related

How to troubleshoot seaborn legend_out not working correctly with catplot or relplot?

With seaborn 0.11.1 and matplotlib 3.3.4 this...
import matplotlib as mpl
from matplotlib import pyplot as plt
print(sns.__version__, mpl.__version__)
import seaborn as sns
sns.set_theme(style="ticks")
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", data=exercise)
plt.show()
...the result is supposed to look like this:
However, when I do that in JupyterLab or Plotly-Dash I get:
I deleted ~/.config/matplotlib and setup a clean conda environment with minimal packages. Same result.
plt.rcParams['figure.autolayout'] = False
fixes it.

Importing gensim

I've installed gensim, however I keep getting an error when I try to import it
from gensim.models import Word2Vec
ImportError: cannot import name 'open'
I'm using the updated version of gensim 3.8.0 and smart_open 2.1.0.
I have reinstalled several times but still can't get it to work.
I also have the same problem, after that I found a solution:
pip install --upgrade gensim
You can install first , then you can import:
import gensim.downloader as gensim_api
import gensim
Works for Mac.

Tensorflow .so issues Mac OS X

I am having trouble getting the Tensorflow example to progress beyond the first line of code beyond my imports. With no other errors, I receive the following:
NotFoundError: dlopen(/Users/opusandcaymus/Election/word2vec_ops.so, 6): image not found
I have a dedicated Tensorflow environment in Anaconda 4.0.1 running Python 3.5. Tensorflow was freshly installed in that environment as version 1.4.1. I'm not sure what the .os file does for word2vec, but Google's example problem requires this line (Google Example Link). Thanks in advance.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import sys
import threading
import time
from six.moves import xrange # pylint: disable=redefined-builtin
import numpy as np
import tensorflow as tf
word2vec = tf.load_op_library(os.path.join(os.path.dirname(os.path.realpath("__file__")), 'word2vec_ops.so'))

Numpy and Pandas Not Working in Jupyter Notebook on Mac

I have both Python 2.7 and 3.6 working on my machine. Numpy and Pandas both load, for either version of Python, in the terminal. However, when I try to access them from inside Jupyter notebook, I get the following error messages:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-4ee716103900> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Here is a screenshot of the problem as well:
If you look in the top right hand corner of the screenshot, you will notice where it says "Python3". I have seen video tutorials on Jupyter where clicking on that button generates a drop down list, allowing users to select alternate versions of Python. However, when I click on that button, nothing happens.
I noticed that a similar question was asked before here:
numpy & pandas 'ModuleNotFoundEror' in Jupyter notebook (Python 3)
However, very little information was provided and no resolution seems to have been found.
Another similar question provided a hint at an answer that was slightly more promising. It suggested running the following code both from terminal and from inside Jupyter, to make sure they match.
import sys; sys.executable
failed to import numpy as np when I worked with jupyter notebook
From terminal using Python 2.7.10>>
import sys; sys.executable
'/usr/bin/python'
From terminal using Python 3.6.1>>
import sys; sys.executable
'/usr/local/bin/python3'
From Jupyter>>
'/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6'
Have you checked this solution:
Failure to import numpy in Jupyter notebook ?
In your Jupyter screenshot, you're using a Python 3 kernel.
Make sure you have NumPy (and any others you might want to use) installed in your selected Python 3 environment.

How to import packages/modules into spyder?

I just installed python in my MacOS using the Anaconda distribution. My problem is although the packages (eg. matplotlib, numpy, scipy) came included with the installation, I have to import them to spyder every time which is tedious and it's also tiring that that I have to remind spyder of their functionalities.
For eg, in Windows, I only needed to type in the console:
x=array([...,...,...])
but in my mac it would have to be:
import numpy as py
and then type into the console:
x=py.array([...,...,...])
I do notice that in that the spyder-python console (Windows version), there is a text saying,
Imported NumPy 1.8.1, SciPy 0.13.3, Matplotlib 1.3.1 + guidata 1.6.1, guiqwt 2.3.2
Type "scientific" for more details.
That is probably the reason why I don't have to import anything in Windows because Spyder already did it.
How do I do the same for Mac?
Thank you

Resources