Repository: spyder-ide/spyder

Issue:
Numpy arrays not writable
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

whenever i open a variable in variable explorer, i can only resize but neither the format and change background color option is working.
plz respond to this problem.



## Versions

* Spyder version: 4.0.1 
* Python version: 3.7.4
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 10

### Dependencies

```
atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.2.2 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.10.2 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.7 (OK)
pygments >=2.0               :  2.5.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.2 (OK)
zmq >=17                     :  18.1.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
sphinx >=0.6.6               :  2.3.0 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  0.29.14 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
numpy >=1.7                  :  1.17.4 (OK)
pandas >=0.13.1              :  0.25.3 (OK)
scipy >=0.17.0               :  1.3.2 (OK)
sympy >=0.7.3                :  1.5 (OK)
```



Discussion:
I don't understand what you mean. Please post some screenshots of your problem.
![problem](https://user-images.githubusercontent.com/33214238/72550165-225ed680-38b8-11ea-9d71-b6439ff03229.PNG)
Unable to use format and background color option.
Ok, I understand your problem now. Please post the code you used to generate that array so we can reproduce it in our side.
import numpy as np
import pandas as pd

dataset = pd.read_csv("Data.csv")
X=dataset.iloc[:,:-1].values
Y=dataset.iloc[:,3].values
That's not reproducible because we don't have the contents of Data.csv. Please upload that file too. 



[Data.xlsx](https://github.com/spyder-ide/spyder/files/4077705/Data.xlsx)

Sorry for not answering before. I think the problem is that Numpy arrays obtained like this

    X=dataset.iloc[:,:-1].values

are object arrays, and those are read-only by default.
@steff456, please verify if my assumption is correct. If that's the case, we need to change the window title of our array editor (see the screenshot in https://github.com/spyder-ide/spyder/issues/11331#issuecomment-575272837) from `NumPy array (read only)` to `NumPy object array (read only)`.

I think that's the best we can do in this case.
Thanks for your help.
Yes your assumption is correct.

On Sat, 25 Jan 2020, 22:53 Carlos Cordoba, <notifications@github.com> wrote:

> @steff456 <https://github.com/steff456>, please verify if my assumption
> is correct. If that's the case, we need to change the window title of our
> array editor (see the screenshot in #11331 (comment)
> <https://github.com/spyder-ide/spyder/issues/11331#issuecomment-575272837>)
> from NumPy array (read only) to NumPy object array (read only).
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> <https://github.com/spyder-ide/spyder/issues/11331?email_source=notifications&email_token=AH5M6HQGNNUENBVU3JXZON3Q7RYQDA5CNFSM4KHVKGM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ5A76I#issuecomment-578424825>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AH5M6HW7EGO3Q5NUP6DR5XLQ7RYQDANCNFSM4KHVKGMQ>
> .
>

@ab-5860, thanks for confirming it! The thing is object arrays can't be edited because we don't know what kind of elements they contain (i.e. they can contain strings, numbers, lists, etc).

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/arrayeditor.py b/spyder/plugins/variableexplorer/widgets/arrayeditor.py
--- a/spyder/plugins/variableexplorer/widgets/arrayeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/arrayeditor.py
@@ -691,7 +691,7 @@ def setup_and_check(self, data, title='', readonly=False,
         self.setLayout(self.layout)
         self.setWindowIcon(ima.icon('arredit'))
         if title:
-            title = to_text_string(title) + " - " + _("NumPy array")
+            title = to_text_string(title) + " - " + _("NumPy object array")
         else:
             title = _("Array editor")
         if readonly:


Test patch: