Created
February 27, 2020 21:48
-
-
Save glemaitre/a5f76135a8426d892a264a0b93edcc40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import numpy as np | |
In [2]: X = ["One", "string"] | |
In [3]: X | |
Out[3]: ['One', 'string'] | |
In [4]: X[0] | |
Out[4]: 'One' | |
In [5]: type(X[0]) | |
Out[5]: str | |
In [6]: X = np.array(X) | |
In [7]: X | |
Out[7]: array(['One', 'string'], dtype='<U6') | |
In [8]: X[1] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
In [9]: X | |
Out[9]: array(['One', 'xxxxxx'], dtype='<U6') | |
In [10]: X = X.astype(object) | |
In [11]: X | |
Out[11]: array(['One', 'xxxxxx'], dtype=object) | |
In [12]: X[1] = "yyyyyyyyyyyyyyyyyy" | |
In [13]: X | |
Out[13]: array(['One', 'yyyyyyyyyyyyyyyyyy'], dtype=object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment