Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failure during variable extraction" when opening data explorer #3423

Closed
luabud opened this issue Apr 21, 2019 · 0 comments
Closed

"Failure during variable extraction" when opening data explorer #3423

luabud opened this issue Apr 21, 2019 · 0 comments
Assignees

Comments

@luabud
Copy link
Member

luabud commented Apr 21, 2019

VS Code Insiders 1.34.0
Extension version 2019.5.6963-dev

I ran a piece of code in the Python interactive window and then clicked on "Show variable in data explorer" for a ndarray. This is the error I got:

image

Developer tools output:

workbench.main.js:236 [Extension Host] Python Extension: Failure during variable extraction:
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-2-45f79c0cea73> in <module>
     36         _VSCODE_columnNames = list(_VSCODE_evalResult)
     37     elif _VSCODE_targetVariable['type'] == 'ndarray':
---> 38         _VSCODE_evalResult = _VSCODE_pd.Series(_VSCODE_evalResult)
     39         _VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
     40         _VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)

~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    260             else:
    261                 data = sanitize_array(data, index, dtype, copy,
--> 262                                       raise_cast_failure=True)
    263 
    264                 data = SingleBlockManager(data, index, fastpath=True)

~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\internals\construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
    656     elif subarr.ndim > 1:
    657         if isinstance(data, np.ndarray):
--> 658             raise Exception('Data must be 1-dimensional')
    659         else:
    660             subarr = com.asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional (at r.logError (C:\Users\luabud\.vscode-insiders\extensions\ms-python.python-2019.5.6963-dev\out\client\extension.js:1:16640))
t.log @ workbench.main.js:236
workbench.main.js:2362 Error: Failure during variable extraction: --------------------------------------------------------------------------- Exception                                 Traceback (most recent call last) <ipython-input-2-45f79c0cea73> in <module>      36         _VSCODE_columnNames = list(_VSCODE_evalResult)      37     elif _VSCODE_targetVariable['type'] == 'ndarray': ---> 38         _VSCODE_evalResult = _VSCODE_pd.Series(_VSCODE_evalResult)      39         _VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)      40         _VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)  ~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath)     260             else:     261                 data = sanitize_array(data, index, dtype, copy, --> 262                                       raise_cast_failure=True)     263      264                 data = SingleBlockManager(data, index, fastpath=True)  ~\Ap...
onDidNotificationChange @ workbench.main.js:2362

Code:

print(__doc__)


# Code source: Gaël Varoquaux
# Modified for documentation by Jaques Grobler
# License: BSD 3 clause

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn import datasets
from sklearn.decomposition import PCA

# import some data to play with
iris = datasets.load_iris()
X = iris.data[:, :2]  # we only take the first two features.
y = iris.target

x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5

plt.figure(2, figsize=(8, 6))
plt.clf()

# Plot the training points
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Set1,
            edgecolor='k')
plt.xlabel('Sepal length')
plt.ylabel('Sepal width')

plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)
plt.xticks(())
plt.yticks(())

# To getter a better understanding of interaction of the dimensions
# plot the first three PCA dimensions
fig = plt.figure(1, figsize=(8, 6))
ax = Axes3D(fig, elev=-150, azim=110)
X_reduced = PCA(n_components=3).fit_transform(iris.data)
ax.scatter(X_reduced[:, 0], X_reduced[:, 1], X_reduced[:, 2], c=y,
           cmap=plt.cm.Set1, edgecolor='k', s=40)
ax.set_title("First three PCA directions")
ax.set_xlabel("1st eigenvector")
ax.w_xaxis.set_ticklabels([])
ax.set_ylabel("2nd eigenvector")
ax.w_yaxis.set_ticklabels([])
ax.set_zlabel("3rd eigenvector")
ax.w_zaxis.set_ticklabels([])

plt.show()
@rchiodo rchiodo self-assigned this Apr 22, 2019
@rchiodo rchiodo closed this as completed Apr 24, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 22, 2019
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants