Problem regarding np array - change the dtype











up vote
-2
down vote

favorite












Is there any method to make the following "list" removed?



Alright, I want to clarify how I generate p and I would like to simply p to make it easy to be read:



a=['Date,value','20180101,200','20180201,300']
p=np.empty(3,dtype=object)
for k in range(0,3,1):
p[k]=a[k+1].split(","),
p


OUTPUT:



>>> p
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)


Also, I have tried:



p.ravel()
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)









share|improve this question
























  • How do you generate p ?
    – Patol75
    Nov 22 at 9:45










  • @Patol75 i have edited it please have a look thanks
    – Alana
    Nov 23 at 15:16















up vote
-2
down vote

favorite












Is there any method to make the following "list" removed?



Alright, I want to clarify how I generate p and I would like to simply p to make it easy to be read:



a=['Date,value','20180101,200','20180201,300']
p=np.empty(3,dtype=object)
for k in range(0,3,1):
p[k]=a[k+1].split(","),
p


OUTPUT:



>>> p
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)


Also, I have tried:



p.ravel()
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)









share|improve this question
























  • How do you generate p ?
    – Patol75
    Nov 22 at 9:45










  • @Patol75 i have edited it please have a look thanks
    – Alana
    Nov 23 at 15:16













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











Is there any method to make the following "list" removed?



Alright, I want to clarify how I generate p and I would like to simply p to make it easy to be read:



a=['Date,value','20180101,200','20180201,300']
p=np.empty(3,dtype=object)
for k in range(0,3,1):
p[k]=a[k+1].split(","),
p


OUTPUT:



>>> p
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)


Also, I have tried:



p.ravel()
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)









share|improve this question















Is there any method to make the following "list" removed?



Alright, I want to clarify how I generate p and I would like to simply p to make it easy to be read:



a=['Date,value','20180101,200','20180201,300']
p=np.empty(3,dtype=object)
for k in range(0,3,1):
p[k]=a[k+1].split(","),
p


OUTPUT:



>>> p
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)


Also, I have tried:



p.ravel()
array([(['20180101', '200'],), (['20180201', '300'],), None], dtype=object)






python arrays






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 at 15:15

























asked Nov 22 at 9:43









Alana

12




12












  • How do you generate p ?
    – Patol75
    Nov 22 at 9:45










  • @Patol75 i have edited it please have a look thanks
    – Alana
    Nov 23 at 15:16


















  • How do you generate p ?
    – Patol75
    Nov 22 at 9:45










  • @Patol75 i have edited it please have a look thanks
    – Alana
    Nov 23 at 15:16
















How do you generate p ?
– Patol75
Nov 22 at 9:45




How do you generate p ?
– Patol75
Nov 22 at 9:45












@Patol75 i have edited it please have a look thanks
– Alana
Nov 23 at 15:16




@Patol75 i have edited it please have a look thanks
– Alana
Nov 23 at 15:16












1 Answer
1






active

oldest

votes

















up vote
0
down vote













ravel



Use ravel to get a unique array from the lists:



my_array = np.array([list([['2018-11-12', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '0']]),
list([['2018-11-13', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '0']]),
list([['2018-11-14', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '0']]),
list([['2018-11-15', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '0']]),
list([['2018-11-16', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '0']])],
dtype=object)

my_array.ravel()

array(['2018-11-12', '25633.199219', '25633.199219', '25633.199219',
'25633.199219', '25633.199219', '0', '2018-11-13', '25792.900391',
'25792.900391', '25792.900391', '25792.900391', '25792.900391',
'0', '2018-11-14', '25654.400391', '25654.400391', '25654.400391',
'25654.400391', '25654.400391', '0', '2018-11-15', '26103.300781',
'26103.300781', '26103.300781', '26103.300781', '26103.300781',
'0', '2018-11-16', '26183.500000', '26183.500000', '26183.500000',
'26183.500000', '26183.500000', '0'], dtype=object)





share|improve this answer























  • Thanks for answering. However, it looks the same after trying it
    – Alana
    Nov 22 at 9:50










  • It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
    – nixon
    Nov 22 at 9:52












  • Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
    – Alana
    Nov 23 at 15:16













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',
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%2f53427961%2fproblem-regarding-np-array-change-the-dtype%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













ravel



Use ravel to get a unique array from the lists:



my_array = np.array([list([['2018-11-12', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '0']]),
list([['2018-11-13', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '0']]),
list([['2018-11-14', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '0']]),
list([['2018-11-15', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '0']]),
list([['2018-11-16', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '0']])],
dtype=object)

my_array.ravel()

array(['2018-11-12', '25633.199219', '25633.199219', '25633.199219',
'25633.199219', '25633.199219', '0', '2018-11-13', '25792.900391',
'25792.900391', '25792.900391', '25792.900391', '25792.900391',
'0', '2018-11-14', '25654.400391', '25654.400391', '25654.400391',
'25654.400391', '25654.400391', '0', '2018-11-15', '26103.300781',
'26103.300781', '26103.300781', '26103.300781', '26103.300781',
'0', '2018-11-16', '26183.500000', '26183.500000', '26183.500000',
'26183.500000', '26183.500000', '0'], dtype=object)





share|improve this answer























  • Thanks for answering. However, it looks the same after trying it
    – Alana
    Nov 22 at 9:50










  • It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
    – nixon
    Nov 22 at 9:52












  • Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
    – Alana
    Nov 23 at 15:16

















up vote
0
down vote













ravel



Use ravel to get a unique array from the lists:



my_array = np.array([list([['2018-11-12', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '0']]),
list([['2018-11-13', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '0']]),
list([['2018-11-14', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '0']]),
list([['2018-11-15', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '0']]),
list([['2018-11-16', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '0']])],
dtype=object)

my_array.ravel()

array(['2018-11-12', '25633.199219', '25633.199219', '25633.199219',
'25633.199219', '25633.199219', '0', '2018-11-13', '25792.900391',
'25792.900391', '25792.900391', '25792.900391', '25792.900391',
'0', '2018-11-14', '25654.400391', '25654.400391', '25654.400391',
'25654.400391', '25654.400391', '0', '2018-11-15', '26103.300781',
'26103.300781', '26103.300781', '26103.300781', '26103.300781',
'0', '2018-11-16', '26183.500000', '26183.500000', '26183.500000',
'26183.500000', '26183.500000', '0'], dtype=object)





share|improve this answer























  • Thanks for answering. However, it looks the same after trying it
    – Alana
    Nov 22 at 9:50










  • It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
    – nixon
    Nov 22 at 9:52












  • Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
    – Alana
    Nov 23 at 15:16















up vote
0
down vote










up vote
0
down vote









ravel



Use ravel to get a unique array from the lists:



my_array = np.array([list([['2018-11-12', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '0']]),
list([['2018-11-13', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '0']]),
list([['2018-11-14', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '0']]),
list([['2018-11-15', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '0']]),
list([['2018-11-16', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '0']])],
dtype=object)

my_array.ravel()

array(['2018-11-12', '25633.199219', '25633.199219', '25633.199219',
'25633.199219', '25633.199219', '0', '2018-11-13', '25792.900391',
'25792.900391', '25792.900391', '25792.900391', '25792.900391',
'0', '2018-11-14', '25654.400391', '25654.400391', '25654.400391',
'25654.400391', '25654.400391', '0', '2018-11-15', '26103.300781',
'26103.300781', '26103.300781', '26103.300781', '26103.300781',
'0', '2018-11-16', '26183.500000', '26183.500000', '26183.500000',
'26183.500000', '26183.500000', '0'], dtype=object)





share|improve this answer














ravel



Use ravel to get a unique array from the lists:



my_array = np.array([list([['2018-11-12', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '25633.199219', '0']]),
list([['2018-11-13', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '25792.900391', '0']]),
list([['2018-11-14', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '25654.400391', '0']]),
list([['2018-11-15', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '26103.300781', '0']]),
list([['2018-11-16', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '26183.500000', '0']])],
dtype=object)

my_array.ravel()

array(['2018-11-12', '25633.199219', '25633.199219', '25633.199219',
'25633.199219', '25633.199219', '0', '2018-11-13', '25792.900391',
'25792.900391', '25792.900391', '25792.900391', '25792.900391',
'0', '2018-11-14', '25654.400391', '25654.400391', '25654.400391',
'25654.400391', '25654.400391', '0', '2018-11-15', '26103.300781',
'26103.300781', '26103.300781', '26103.300781', '26103.300781',
'0', '2018-11-16', '26183.500000', '26183.500000', '26183.500000',
'26183.500000', '26183.500000', '0'], dtype=object)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 at 9:52

























answered Nov 22 at 9:45









nixon

2,113218




2,113218












  • Thanks for answering. However, it looks the same after trying it
    – Alana
    Nov 22 at 9:50










  • It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
    – nixon
    Nov 22 at 9:52












  • Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
    – Alana
    Nov 23 at 15:16




















  • Thanks for answering. However, it looks the same after trying it
    – Alana
    Nov 22 at 9:50










  • It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
    – nixon
    Nov 22 at 9:52












  • Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
    – Alana
    Nov 23 at 15:16


















Thanks for answering. However, it looks the same after trying it
– Alana
Nov 22 at 9:50




Thanks for answering. However, it looks the same after trying it
– Alana
Nov 22 at 9:50












It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
– nixon
Nov 22 at 9:52






It does the trick for me @Alana. Your data is a np.array, right? Is your input data the same as mine? Notice I just added it in an edit.
– nixon
Nov 22 at 9:52














Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
– Alana
Nov 23 at 15:16






Sorry for late reply I have changed a bit and added how i generate p however the problem still exist @Alexandre Nixon
– Alana
Nov 23 at 15:16




















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%2f53427961%2fproblem-regarding-np-array-change-the-dtype%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

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks