How to transfer an str Series into a two dimensional ndarray? [closed]












0















enter image description here



this is my data



and I wanna transfer it into a two dimensional ndarray, I have tried many methods, like np.from_string, pd.pd.to_numeric, but I can't solve it



thanks in advanced.










share|improve this question













closed as unclear what you're asking by Vega, AdrianHHH, Gert Arnold, sideshowbarker, Makyen Nov 24 '18 at 21:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • Please add code, errors and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.

    – Makyen
    Nov 24 '18 at 22:00
















0















enter image description here



this is my data



and I wanna transfer it into a two dimensional ndarray, I have tried many methods, like np.from_string, pd.pd.to_numeric, but I can't solve it



thanks in advanced.










share|improve this question













closed as unclear what you're asking by Vega, AdrianHHH, Gert Arnold, sideshowbarker, Makyen Nov 24 '18 at 21:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.



















  • Please add code, errors and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.

    – Makyen
    Nov 24 '18 at 22:00














0












0








0


0






enter image description here



this is my data



and I wanna transfer it into a two dimensional ndarray, I have tried many methods, like np.from_string, pd.pd.to_numeric, but I can't solve it



thanks in advanced.










share|improve this question














enter image description here



this is my data



and I wanna transfer it into a two dimensional ndarray, I have tried many methods, like np.from_string, pd.pd.to_numeric, but I can't solve it



thanks in advanced.







python-3.x pandas numpy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 7:05









duckluducklu

63




63




closed as unclear what you're asking by Vega, AdrianHHH, Gert Arnold, sideshowbarker, Makyen Nov 24 '18 at 21:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by Vega, AdrianHHH, Gert Arnold, sideshowbarker, Makyen Nov 24 '18 at 21:59


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Please add code, errors and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.

    – Makyen
    Nov 24 '18 at 22:00



















  • Please add code, errors and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.

    – Makyen
    Nov 24 '18 at 22:00

















Please add code, errors and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.

– Makyen
Nov 24 '18 at 22:00





Please add code, errors and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.

– Makyen
Nov 24 '18 at 22:00












1 Answer
1






active

oldest

votes


















0














Use list comprehension with split and converting to np.array:



df = pd.DataFrame({'pixels':['70 80 82 72','151 1050 147 155']})
print (df)
pixels
0 70 80 82 72
1 151 1050 147 155

arr = np.array([x.split() for x in df['pixels']]).astype(int)
print (arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]


If data in file:



arr = np.genfromtxt('my_file.csv', delimiter=' ', dtype=np.int64)
print(arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]





share|improve this answer


























  • @ducklu - How was created DataFrame ?

    – jezrael
    Nov 24 '18 at 7:13











  • I download the data in an image database for the emotion recognition

    – ducklu
    Nov 24 '18 at 7:17











  • @ducklu - link is possible see?

    – jezrael
    Nov 24 '18 at 7:18











  • it's fer_2013 from Kaggle, but I forget the link, sorry

    – ducklu
    Nov 24 '18 at 7:21


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Use list comprehension with split and converting to np.array:



df = pd.DataFrame({'pixels':['70 80 82 72','151 1050 147 155']})
print (df)
pixels
0 70 80 82 72
1 151 1050 147 155

arr = np.array([x.split() for x in df['pixels']]).astype(int)
print (arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]


If data in file:



arr = np.genfromtxt('my_file.csv', delimiter=' ', dtype=np.int64)
print(arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]





share|improve this answer


























  • @ducklu - How was created DataFrame ?

    – jezrael
    Nov 24 '18 at 7:13











  • I download the data in an image database for the emotion recognition

    – ducklu
    Nov 24 '18 at 7:17











  • @ducklu - link is possible see?

    – jezrael
    Nov 24 '18 at 7:18











  • it's fer_2013 from Kaggle, but I forget the link, sorry

    – ducklu
    Nov 24 '18 at 7:21
















0














Use list comprehension with split and converting to np.array:



df = pd.DataFrame({'pixels':['70 80 82 72','151 1050 147 155']})
print (df)
pixels
0 70 80 82 72
1 151 1050 147 155

arr = np.array([x.split() for x in df['pixels']]).astype(int)
print (arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]


If data in file:



arr = np.genfromtxt('my_file.csv', delimiter=' ', dtype=np.int64)
print(arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]





share|improve this answer


























  • @ducklu - How was created DataFrame ?

    – jezrael
    Nov 24 '18 at 7:13











  • I download the data in an image database for the emotion recognition

    – ducklu
    Nov 24 '18 at 7:17











  • @ducklu - link is possible see?

    – jezrael
    Nov 24 '18 at 7:18











  • it's fer_2013 from Kaggle, but I forget the link, sorry

    – ducklu
    Nov 24 '18 at 7:21














0












0








0







Use list comprehension with split and converting to np.array:



df = pd.DataFrame({'pixels':['70 80 82 72','151 1050 147 155']})
print (df)
pixels
0 70 80 82 72
1 151 1050 147 155

arr = np.array([x.split() for x in df['pixels']]).astype(int)
print (arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]


If data in file:



arr = np.genfromtxt('my_file.csv', delimiter=' ', dtype=np.int64)
print(arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]





share|improve this answer















Use list comprehension with split and converting to np.array:



df = pd.DataFrame({'pixels':['70 80 82 72','151 1050 147 155']})
print (df)
pixels
0 70 80 82 72
1 151 1050 147 155

arr = np.array([x.split() for x in df['pixels']]).astype(int)
print (arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]


If data in file:



arr = np.genfromtxt('my_file.csv', delimiter=' ', dtype=np.int64)
print(arr)
[[ 70 80 82 72]
[ 151 1050 147 155]]






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 24 '18 at 7:20

























answered Nov 24 '18 at 7:06









jezraeljezrael

329k23270349




329k23270349













  • @ducklu - How was created DataFrame ?

    – jezrael
    Nov 24 '18 at 7:13











  • I download the data in an image database for the emotion recognition

    – ducklu
    Nov 24 '18 at 7:17











  • @ducklu - link is possible see?

    – jezrael
    Nov 24 '18 at 7:18











  • it's fer_2013 from Kaggle, but I forget the link, sorry

    – ducklu
    Nov 24 '18 at 7:21



















  • @ducklu - How was created DataFrame ?

    – jezrael
    Nov 24 '18 at 7:13











  • I download the data in an image database for the emotion recognition

    – ducklu
    Nov 24 '18 at 7:17











  • @ducklu - link is possible see?

    – jezrael
    Nov 24 '18 at 7:18











  • it's fer_2013 from Kaggle, but I forget the link, sorry

    – ducklu
    Nov 24 '18 at 7:21

















@ducklu - How was created DataFrame ?

– jezrael
Nov 24 '18 at 7:13





@ducklu - How was created DataFrame ?

– jezrael
Nov 24 '18 at 7:13













I download the data in an image database for the emotion recognition

– ducklu
Nov 24 '18 at 7:17





I download the data in an image database for the emotion recognition

– ducklu
Nov 24 '18 at 7:17













@ducklu - link is possible see?

– jezrael
Nov 24 '18 at 7:18





@ducklu - link is possible see?

– jezrael
Nov 24 '18 at 7:18













it's fer_2013 from Kaggle, but I forget the link, sorry

– ducklu
Nov 24 '18 at 7:21





it's fer_2013 from Kaggle, but I forget the link, sorry

– ducklu
Nov 24 '18 at 7:21



Popular posts from this blog

Basket-ball féminin

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...

I want to find a topological embedding $f : X rightarrow Y$ and $g: Y rightarrow X$, yet $X$ is not...