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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







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

359k26327404




359k26327404













  • @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





這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()