how can I reshape a numpy array of (100,) to (250,100)












-1














Imagine that you have created an array with 100 dimensions and then you calculate something and fill this array. for whatever reason, you have not created 2d array, what is wrong with this question that you want to assign another dimension to this data, with this justification that for example 250 samples should have this calculated data?!!



I have searched this but I could not find any solution. Maybe I am not searching with correct keyword!



Actually I want to reshape a numpy array of (100,) to (250,100).
I have read this link and a couple of other links but did not help me.



I have also tried this way:



numpyarray = (100,)
transformed_numpyarray = np.reshape(numpyarray,(100,-1)).T


which gives me this output:



(1, 100)


but I really do not want 1 as the first item of 2d array.
what Im trying to do is to either convert to (,100) or at least something like this (250,100). "250" is a constant number I know already so I want to say for example for 250 samples with 100 dimension.



Thanks.










share|improve this question




















  • 3




    (100,) is standard python notation for a 1 element tuple. (,100) is not valid python syntax.
    – hpaulj
    Nov 21 at 1:54










  • np.reshape(numpyarray,(100,-1)) gives an error, cannot reshape array of size 1 into shape (100,newaxis). Your description confuses arrays and their shapes.
    – hpaulj
    Nov 21 at 2:42










  • Your link is to a keras question. there (None, 100) is a valid shape. There isn't a numpy equivalent.
    – hpaulj
    Nov 21 at 2:43










  • @hpaulj thank you so much for your explanations. though (,100) may not be a valid but I need it to be in this way. Or Im gonna to update my question to another way. I will be ok to update (100,) to (250,100). 250 is something constant. is in this way is doable?
    – sariii
    Nov 21 at 3:30






  • 1




    Question has nothing to do with machine-learning or scikit-learn - kindly do not spam the tags (removed).
    – desertnaut
    Nov 21 at 12:14
















-1














Imagine that you have created an array with 100 dimensions and then you calculate something and fill this array. for whatever reason, you have not created 2d array, what is wrong with this question that you want to assign another dimension to this data, with this justification that for example 250 samples should have this calculated data?!!



I have searched this but I could not find any solution. Maybe I am not searching with correct keyword!



Actually I want to reshape a numpy array of (100,) to (250,100).
I have read this link and a couple of other links but did not help me.



I have also tried this way:



numpyarray = (100,)
transformed_numpyarray = np.reshape(numpyarray,(100,-1)).T


which gives me this output:



(1, 100)


but I really do not want 1 as the first item of 2d array.
what Im trying to do is to either convert to (,100) or at least something like this (250,100). "250" is a constant number I know already so I want to say for example for 250 samples with 100 dimension.



Thanks.










share|improve this question




















  • 3




    (100,) is standard python notation for a 1 element tuple. (,100) is not valid python syntax.
    – hpaulj
    Nov 21 at 1:54










  • np.reshape(numpyarray,(100,-1)) gives an error, cannot reshape array of size 1 into shape (100,newaxis). Your description confuses arrays and their shapes.
    – hpaulj
    Nov 21 at 2:42










  • Your link is to a keras question. there (None, 100) is a valid shape. There isn't a numpy equivalent.
    – hpaulj
    Nov 21 at 2:43










  • @hpaulj thank you so much for your explanations. though (,100) may not be a valid but I need it to be in this way. Or Im gonna to update my question to another way. I will be ok to update (100,) to (250,100). 250 is something constant. is in this way is doable?
    – sariii
    Nov 21 at 3:30






  • 1




    Question has nothing to do with machine-learning or scikit-learn - kindly do not spam the tags (removed).
    – desertnaut
    Nov 21 at 12:14














-1












-1








-1







Imagine that you have created an array with 100 dimensions and then you calculate something and fill this array. for whatever reason, you have not created 2d array, what is wrong with this question that you want to assign another dimension to this data, with this justification that for example 250 samples should have this calculated data?!!



I have searched this but I could not find any solution. Maybe I am not searching with correct keyword!



Actually I want to reshape a numpy array of (100,) to (250,100).
I have read this link and a couple of other links but did not help me.



I have also tried this way:



numpyarray = (100,)
transformed_numpyarray = np.reshape(numpyarray,(100,-1)).T


which gives me this output:



(1, 100)


but I really do not want 1 as the first item of 2d array.
what Im trying to do is to either convert to (,100) or at least something like this (250,100). "250" is a constant number I know already so I want to say for example for 250 samples with 100 dimension.



Thanks.










share|improve this question















Imagine that you have created an array with 100 dimensions and then you calculate something and fill this array. for whatever reason, you have not created 2d array, what is wrong with this question that you want to assign another dimension to this data, with this justification that for example 250 samples should have this calculated data?!!



I have searched this but I could not find any solution. Maybe I am not searching with correct keyword!



Actually I want to reshape a numpy array of (100,) to (250,100).
I have read this link and a couple of other links but did not help me.



I have also tried this way:



numpyarray = (100,)
transformed_numpyarray = np.reshape(numpyarray,(100,-1)).T


which gives me this output:



(1, 100)


but I really do not want 1 as the first item of 2d array.
what Im trying to do is to either convert to (,100) or at least something like this (250,100). "250" is a constant number I know already so I want to say for example for 250 samples with 100 dimension.



Thanks.







python numpy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 17:11

























asked Nov 21 at 1:27









sariii

4161316




4161316








  • 3




    (100,) is standard python notation for a 1 element tuple. (,100) is not valid python syntax.
    – hpaulj
    Nov 21 at 1:54










  • np.reshape(numpyarray,(100,-1)) gives an error, cannot reshape array of size 1 into shape (100,newaxis). Your description confuses arrays and their shapes.
    – hpaulj
    Nov 21 at 2:42










  • Your link is to a keras question. there (None, 100) is a valid shape. There isn't a numpy equivalent.
    – hpaulj
    Nov 21 at 2:43










  • @hpaulj thank you so much for your explanations. though (,100) may not be a valid but I need it to be in this way. Or Im gonna to update my question to another way. I will be ok to update (100,) to (250,100). 250 is something constant. is in this way is doable?
    – sariii
    Nov 21 at 3:30






  • 1




    Question has nothing to do with machine-learning or scikit-learn - kindly do not spam the tags (removed).
    – desertnaut
    Nov 21 at 12:14














  • 3




    (100,) is standard python notation for a 1 element tuple. (,100) is not valid python syntax.
    – hpaulj
    Nov 21 at 1:54










  • np.reshape(numpyarray,(100,-1)) gives an error, cannot reshape array of size 1 into shape (100,newaxis). Your description confuses arrays and their shapes.
    – hpaulj
    Nov 21 at 2:42










  • Your link is to a keras question. there (None, 100) is a valid shape. There isn't a numpy equivalent.
    – hpaulj
    Nov 21 at 2:43










  • @hpaulj thank you so much for your explanations. though (,100) may not be a valid but I need it to be in this way. Or Im gonna to update my question to another way. I will be ok to update (100,) to (250,100). 250 is something constant. is in this way is doable?
    – sariii
    Nov 21 at 3:30






  • 1




    Question has nothing to do with machine-learning or scikit-learn - kindly do not spam the tags (removed).
    – desertnaut
    Nov 21 at 12:14








3




3




(100,) is standard python notation for a 1 element tuple. (,100) is not valid python syntax.
– hpaulj
Nov 21 at 1:54




(100,) is standard python notation for a 1 element tuple. (,100) is not valid python syntax.
– hpaulj
Nov 21 at 1:54












np.reshape(numpyarray,(100,-1)) gives an error, cannot reshape array of size 1 into shape (100,newaxis). Your description confuses arrays and their shapes.
– hpaulj
Nov 21 at 2:42




np.reshape(numpyarray,(100,-1)) gives an error, cannot reshape array of size 1 into shape (100,newaxis). Your description confuses arrays and their shapes.
– hpaulj
Nov 21 at 2:42












Your link is to a keras question. there (None, 100) is a valid shape. There isn't a numpy equivalent.
– hpaulj
Nov 21 at 2:43




Your link is to a keras question. there (None, 100) is a valid shape. There isn't a numpy equivalent.
– hpaulj
Nov 21 at 2:43












@hpaulj thank you so much for your explanations. though (,100) may not be a valid but I need it to be in this way. Or Im gonna to update my question to another way. I will be ok to update (100,) to (250,100). 250 is something constant. is in this way is doable?
– sariii
Nov 21 at 3:30




@hpaulj thank you so much for your explanations. though (,100) may not be a valid but I need it to be in this way. Or Im gonna to update my question to another way. I will be ok to update (100,) to (250,100). 250 is something constant. is in this way is doable?
– sariii
Nov 21 at 3:30




1




1




Question has nothing to do with machine-learning or scikit-learn - kindly do not spam the tags (removed).
– desertnaut
Nov 21 at 12:14




Question has nothing to do with machine-learning or scikit-learn - kindly do not spam the tags (removed).
– desertnaut
Nov 21 at 12:14












2 Answers
2






active

oldest

votes


















1














I'm still confused about what you are trying to do. So far I can picture two alternatives - reshape and repeat. To illustrate:



In [148]: x = np.arange(16)
In [149]: x
Out[149]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])

In [150]: x.reshape(4,4)
Out[150]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])

In [151]: np.repeat(x[None,:], 4, axis=0)
Out[151]:
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]])





share|improve this answer





















  • exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
    – sariii
    Nov 22 at 17:10










  • Do you mind explaining why do we need this part x.reshape(4,4)?
    – sariii
    Nov 22 at 17:13










  • No sorry, it seems you have not used it ;)
    – sariii
    Nov 22 at 17:14



















1














numpy's arrays are static sized, you can't have an array with a variable shape. If you don't know beforehand how many samples you will have you can gradually add them with vstack:



In [4]: numpyarray.shape                                                        
Out[4]: (3, 4)

In [5]: new_sample.shape
Out[5]: (4,)

In [6]: numpyarray = np.vstack([numpyarray, new_sample])

In [7]: numpyarray.shape
Out[7]: (4, 4)


you can also first define the size by creating an array full of zeros and then progressively fill it with samples.



numpyarray = np.zeros((250,100))
...
numpyarray[i] = new_sample





share|improve this answer























  • thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
    – sariii
    Nov 21 at 3:25










  • I also updated my question. in case it will be easier to convert to a constant number like 250
    – sariii
    Nov 21 at 3:34






  • 1




    The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
    – vlizana
    Nov 21 at 3:45






  • 1




    thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
    – sariii
    Nov 21 at 4:08













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404047%2fhow-can-i-reshape-a-numpy-array-of-100-to-250-100%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I'm still confused about what you are trying to do. So far I can picture two alternatives - reshape and repeat. To illustrate:



In [148]: x = np.arange(16)
In [149]: x
Out[149]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])

In [150]: x.reshape(4,4)
Out[150]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])

In [151]: np.repeat(x[None,:], 4, axis=0)
Out[151]:
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]])





share|improve this answer





















  • exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
    – sariii
    Nov 22 at 17:10










  • Do you mind explaining why do we need this part x.reshape(4,4)?
    – sariii
    Nov 22 at 17:13










  • No sorry, it seems you have not used it ;)
    – sariii
    Nov 22 at 17:14
















1














I'm still confused about what you are trying to do. So far I can picture two alternatives - reshape and repeat. To illustrate:



In [148]: x = np.arange(16)
In [149]: x
Out[149]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])

In [150]: x.reshape(4,4)
Out[150]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])

In [151]: np.repeat(x[None,:], 4, axis=0)
Out[151]:
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]])





share|improve this answer





















  • exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
    – sariii
    Nov 22 at 17:10










  • Do you mind explaining why do we need this part x.reshape(4,4)?
    – sariii
    Nov 22 at 17:13










  • No sorry, it seems you have not used it ;)
    – sariii
    Nov 22 at 17:14














1












1








1






I'm still confused about what you are trying to do. So far I can picture two alternatives - reshape and repeat. To illustrate:



In [148]: x = np.arange(16)
In [149]: x
Out[149]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])

In [150]: x.reshape(4,4)
Out[150]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])

In [151]: np.repeat(x[None,:], 4, axis=0)
Out[151]:
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]])





share|improve this answer












I'm still confused about what you are trying to do. So far I can picture two alternatives - reshape and repeat. To illustrate:



In [148]: x = np.arange(16)
In [149]: x
Out[149]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])

In [150]: x.reshape(4,4)
Out[150]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])

In [151]: np.repeat(x[None,:], 4, axis=0)
Out[151]:
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]])






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 16:59









hpaulj

110k774140




110k774140












  • exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
    – sariii
    Nov 22 at 17:10










  • Do you mind explaining why do we need this part x.reshape(4,4)?
    – sariii
    Nov 22 at 17:13










  • No sorry, it seems you have not used it ;)
    – sariii
    Nov 22 at 17:14


















  • exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
    – sariii
    Nov 22 at 17:10










  • Do you mind explaining why do we need this part x.reshape(4,4)?
    – sariii
    Nov 22 at 17:13










  • No sorry, it seems you have not used it ;)
    – sariii
    Nov 22 at 17:14
















exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
– sariii
Nov 22 at 17:10




exactly this answer meets my requirement. @vlizana also answered correcty but I did not want to apply for loop and make it expensive. Thank you :)
– sariii
Nov 22 at 17:10












Do you mind explaining why do we need this part x.reshape(4,4)?
– sariii
Nov 22 at 17:13




Do you mind explaining why do we need this part x.reshape(4,4)?
– sariii
Nov 22 at 17:13












No sorry, it seems you have not used it ;)
– sariii
Nov 22 at 17:14




No sorry, it seems you have not used it ;)
– sariii
Nov 22 at 17:14













1














numpy's arrays are static sized, you can't have an array with a variable shape. If you don't know beforehand how many samples you will have you can gradually add them with vstack:



In [4]: numpyarray.shape                                                        
Out[4]: (3, 4)

In [5]: new_sample.shape
Out[5]: (4,)

In [6]: numpyarray = np.vstack([numpyarray, new_sample])

In [7]: numpyarray.shape
Out[7]: (4, 4)


you can also first define the size by creating an array full of zeros and then progressively fill it with samples.



numpyarray = np.zeros((250,100))
...
numpyarray[i] = new_sample





share|improve this answer























  • thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
    – sariii
    Nov 21 at 3:25










  • I also updated my question. in case it will be easier to convert to a constant number like 250
    – sariii
    Nov 21 at 3:34






  • 1




    The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
    – vlizana
    Nov 21 at 3:45






  • 1




    thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
    – sariii
    Nov 21 at 4:08


















1














numpy's arrays are static sized, you can't have an array with a variable shape. If you don't know beforehand how many samples you will have you can gradually add them with vstack:



In [4]: numpyarray.shape                                                        
Out[4]: (3, 4)

In [5]: new_sample.shape
Out[5]: (4,)

In [6]: numpyarray = np.vstack([numpyarray, new_sample])

In [7]: numpyarray.shape
Out[7]: (4, 4)


you can also first define the size by creating an array full of zeros and then progressively fill it with samples.



numpyarray = np.zeros((250,100))
...
numpyarray[i] = new_sample





share|improve this answer























  • thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
    – sariii
    Nov 21 at 3:25










  • I also updated my question. in case it will be easier to convert to a constant number like 250
    – sariii
    Nov 21 at 3:34






  • 1




    The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
    – vlizana
    Nov 21 at 3:45






  • 1




    thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
    – sariii
    Nov 21 at 4:08
















1












1








1






numpy's arrays are static sized, you can't have an array with a variable shape. If you don't know beforehand how many samples you will have you can gradually add them with vstack:



In [4]: numpyarray.shape                                                        
Out[4]: (3, 4)

In [5]: new_sample.shape
Out[5]: (4,)

In [6]: numpyarray = np.vstack([numpyarray, new_sample])

In [7]: numpyarray.shape
Out[7]: (4, 4)


you can also first define the size by creating an array full of zeros and then progressively fill it with samples.



numpyarray = np.zeros((250,100))
...
numpyarray[i] = new_sample





share|improve this answer














numpy's arrays are static sized, you can't have an array with a variable shape. If you don't know beforehand how many samples you will have you can gradually add them with vstack:



In [4]: numpyarray.shape                                                        
Out[4]: (3, 4)

In [5]: new_sample.shape
Out[5]: (4,)

In [6]: numpyarray = np.vstack([numpyarray, new_sample])

In [7]: numpyarray.shape
Out[7]: (4, 4)


you can also first define the size by creating an array full of zeros and then progressively fill it with samples.



numpyarray = np.zeros((250,100))
...
numpyarray[i] = new_sample






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 at 3:38

























answered Nov 21 at 2:22









vlizana

638215




638215












  • thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
    – sariii
    Nov 21 at 3:25










  • I also updated my question. in case it will be easier to convert to a constant number like 250
    – sariii
    Nov 21 at 3:34






  • 1




    The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
    – vlizana
    Nov 21 at 3:45






  • 1




    thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
    – sariii
    Nov 21 at 4:08




















  • thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
    – sariii
    Nov 21 at 3:25










  • I also updated my question. in case it will be easier to convert to a constant number like 250
    – sariii
    Nov 21 at 3:34






  • 1




    The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
    – vlizana
    Nov 21 at 3:45






  • 1




    thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
    – sariii
    Nov 21 at 4:08


















thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
– sariii
Nov 21 at 3:25




thanks for the answer, but I got this error after running your example ValueError: all the input array dimensions except for the concatenation axis must match exactly. do you have any idea of this?
– sariii
Nov 21 at 3:25












I also updated my question. in case it will be easier to convert to a constant number like 250
– sariii
Nov 21 at 3:34




I also updated my question. in case it will be easier to convert to a constant number like 250
– sariii
Nov 21 at 3:34




1




1




The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
– vlizana
Nov 21 at 3:45




The first error means that the length of the samples must be the same as the numpyarray concatenation axis, in this case, all of your samples must have shape (100,) or (1,100) and numpyarray must be (n,100). About the update on the question, when you reshape an array the resulting array must have the same number of cells, in this case the resulting array would have a lot more. I edited my answer about how this can be done.
– vlizana
Nov 21 at 3:45




1




1




thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
– sariii
Nov 21 at 4:08






thank you so much. for the explanations of the error, I followed exactly like your example but got that error. your second answer seems doable but I think I need to for loop through the data?. I'm not at work right now. I will try on that and then get back to mark as answer. again thanks for taking the time :)
– sariii
Nov 21 at 4:08




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404047%2fhow-can-i-reshape-a-numpy-array-of-100-to-250-100%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'