Re: [Tutor] pandas data frame
Bachir Bachir via Tutor wrote: > Hi Peter Thank you much for your help its very appreciated ,bellow is an > example of what i need. The main dataframe ( need to be separated into > separate dataframes ). The desired dataframes output correctly as i need > it to be,Thanks much Main dataframendx V_idAverageMean > Peak 0 1 3 2 51 > 2 2 1 62 3 > 4 1 83 1 2 > 2 74 2 3 3 > 65 3 5 3 46 >1 1 1 87 2 > 2 5 108 3 5 > 5 99 1 2 5 > 10102 5 5 911 > 3 4 3 10 Dataframe-1ndx V_id > Average MeanPeak 0 1 3 2 > 53 1 2 2 76 1 1 > 1 89 1 2 5 10 > Dataframe-2ndx V_idAveragMean Peak 1 2 > 2 1 64 2 3 3 > 67 2 2 5 10102 > 5 5 9 Dataframe-3ndx V_idAverageMean > Peak 2 3 4 1 85 3 > 5 3 48 3 5 5 > 9113 4 3 10 Bachir I see that you got an answer over at comp.python.pydata where you managed to get the format a bit more readable ;) I recommend that you go with Goyo's answer, but instead of the hacky use of locals() > >>> locals().update((('dataframe_{}'.format(k), grouper.get_group(k)) > ... for k in grouper.groups)) I recommend that you put the groups into a normal dict groups = {k: g.get_group(k) for k in g.groups} and then access the partial data frames with v_id = 2 groups[v_id] ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] pandas data frame
Hi Peter Thank you much for your help its very appreciated ,bellow is an example of what i need. The main dataframe ( need to be separated into separate dataframes ). The desired dataframes output correctly as i need it to be,Thanks much Main dataframendx V_id Average Mean Peak 0 1 3 2 51 2 2 1 62 3 4 1 83 1 2 2 74 2 3 3 65 3 5 3 46 1 1 1 87 2 2 5 108 3 5 5 99 1 2 5 1010 2 5 5 911 3 4 3 10 Dataframe-1ndx V_id Average Mean Peak 0 1 3 2 53 1 2 2 76 1 1 1 89 1 2 5 10 Dataframe-2ndx V_id Averag Mean Peak 1 2 2 1 64 2 3 3 67 2 2 5 1010 2 5 5 9 Dataframe-3ndx V_id Average Mean Peak 2 3 4 1 85 3 5 3 48 3 5 5 911 3 4 3 10 Bachir On Monday, January 18, 2016 11:25 AM, Peter Otten <__pete...@web.de> wrote: Bachir Bachir wrote: [Bachir, please send your mails to the list, not to me. That way you increase the likelihood to get a good answer] >> On Sunday, January 17, 2016 4:20 PM, Peter Otten <__pete...@web.de> >> wrote: >> Bachir Bachir via Tutor wrote: >>> Hello EverybodyI need to sort a dataframe according to a specific column >>> the create new dataframes according to the sorted columns each new >>> created dataframe should contain the list(set('the sorted element)any >>> help please, i am new in python and pandas thanks muchBachir >> >> Like this? >> >> >>> df >> >> foo bar >> 0 3.3 b >> 1 2.2 b >> 2 7.5 a >> 3 1.1 c >> 4 4.7 a >> >> [5 rows x 2 columns] >> >> >>> df.groupby("bar").sum() >> >> foo >> bar >> a 12.2 >> b 5.5 >> c 1.1 >> >> [3 rows x 1 columns] > Thanks Peter ,This way but i want keep all the table elements only > separate them by a single column I'm sorry, I don't understand what you mean by "separate them by a single column". Can you give an example? What exactly should the sorted version of >> >>> df >> >> foo bar >> 0 3.3 b >> 1 2.2 b >> 2 7.5 a >> 3 1.1 c >> 4 4.7 a >> >> [5 rows x 2 columns] look like? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] pandas data frame
Bachir Bachir wrote: [Bachir, please send your mails to the list, not to me. That way you increase the likelihood to get a good answer] >> On Sunday, January 17, 2016 4:20 PM, Peter Otten <__pete...@web.de> >> wrote: >> Bachir Bachir via Tutor wrote: >>> Hello EverybodyI need to sort a dataframe according to a specific column >>> the create new dataframes according to the sorted columns each new >>> created dataframe should contain the list(set('the sorted element)any >>> help please, i am new in python and pandas thanks muchBachir >> >> Like this? >> >> >>> df >> >> foo bar >> 0 3.3 b >> 1 2.2 b >> 2 7.5 a >> 3 1.1 c >> 4 4.7 a >> >> [5 rows x 2 columns] >> >> >>> df.groupby("bar").sum() >> >> foo >> bar >> a12.2 >> b5.5 >> c1.1 >> >> [3 rows x 1 columns] > Thanks Peter ,This way but i want keep all the table elements only > separate them by a single column I'm sorry, I don't understand what you mean by "separate them by a single column". Can you give an example? What exactly should the sorted version of >> >>> df >> >> foo bar >> 0 3.3 b >> 1 2.2 b >> 2 7.5 a >> 3 1.1 c >> 4 4.7 a >> >> [5 rows x 2 columns] look like? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] pandas data frame
Bachir Bachir via Tutor wrote: > Hello EverybodyI need to sort a dataframe according to a specific column > the create new dataframes according to the sorted columns each new created > dataframe should contain the list(set('the sorted element)any help please > , i am new in python and pandas thanks muchBachir Like this? >>> df foo bar 0 3.3 b 1 2.2 b 2 7.5 a 3 1.1 c 4 4.7 a [5 rows x 2 columns] >>> df.groupby("bar").sum() foo bar a12.2 b 5.5 c 1.1 [3 rows x 1 columns] ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] pandas data frame
On 17/01/16 11:43, Bachir Bachir via Tutor wrote: > i am new in python and pandas thanks muchBachir Hi Bachir, This list is for questions about core Python and its standard library. Although pandas is part of some Python distributions (eg anaconda) it's not really part of the standard library but part of SciPy. There is a dedicated support forum for SciPy and you might get more responses posting there. http://scipy.org/scipylib/mailing-lists.html However, a few folks on this list do use pandas so you might get lucky here. :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] pandas data frame
Hello EverybodyI need to sort a dataframe according to a specific column the create new dataframes according to the sorted columns each new created dataframe should contain the list(set('the sorted element)any help please , i am new in python and pandas thanks muchBachir ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor