Issue
Sorry for this noob question. I recently installed Anaconda Spyder UI for Python on MacOS. Within Spyder you see three windows, the python file (source code), the variable explorer and the IPython console.
I got two problems:
First, the shortcuts do not work. For instance: Run Cell = CTRL+ENTER and Run Cell and Advance is SHIFT+ENTER. But does not work.
Second, the output of the IPython console does not work. Let's assume the following code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Data.csv')
x = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
x
Then the last line should print x as output onto the IPython console. But instead I get only this:
In [1]: runfile('/Users/guest/Development/data.py', wdir='/Users/guest/Development/')
And no Out [1]. Question: What am I doing wrong? I couldn't locate anything in the preferences dialog.
Solution
- You need to use comments of the form
#%%
to break your files in cells, which are blocks of code you can evaluate independently. Then Cmd+Enter and Shift+Enter will work as expected, i.e. they will evaluate the current cell and stay on it or move to the next one, respectively. - About your second question, if you are running a file with the Run command (what you get when you press F5), you need to change your last line to
print(x)
, because Run doesn't print by default.
Answered By - Carlos Cordoba
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.