Re: How to put back a number-based index

2016-05-14 Thread alex wright
I have recently been going through "Data Science From Scratch" which may be interesting. There is a podcast with the author on talk python to me. https://talkpython.fm/episodes/show/56/data-science-from-scratch On Sat, May 14, 2016 at 10:33 AM, Michael Selik wrote: > You might also be interest

Re: How to put back a number-based index

2016-05-14 Thread Michael Selik
You might also be interested in "Python for Data Analysis" for a thorough discussion of Pandas. http://shop.oreilly.com/product/0636920023784.do On Sat, May 14, 2016 at 10:29 AM Michael Selik wrote: > David, it sounds like you'll need a thorough introduction to the basics of > Python. > Check ou

Re: How to put back a number-based index

2016-05-14 Thread Michael Selik
David, it sounds like you'll need a thorough introduction to the basics of Python. Check out the tutorial: https://docs.python.org/3/tutorial/ On Sat, May 14, 2016 at 6:19 AM David Shi wrote: > Hello, Michael, > > I discovered that the problem is "two columns of data are put together" > and "are

Re: How to put back a number-based index

2016-05-14 Thread David Shi via Python-list
Hello, Michael, I discovered that the problem is "two columns of data are put together" and "are recognised as one column". This is very strange.  I would like to understand the subject well. And, how many ways are there to investigate into the nature of objects dynamically? Some object types onl

Re: How to put back a number-based index

2016-05-14 Thread Michael Selik
It looks like you're getting a Series. Apparently more that one row has the same index. On Fri, May 13, 2016 at 11:30 PM Michael Selik wrote: > What were you hoping to get from ``df[0]``? > When you say it "yields nothing" do you mean it raised an error? What was > the error message? > > Have yo

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
What were you hoping to get from ``df[0]``? When you say it "yields nothing" do you mean it raised an error? What was the error message? Have you tried a Google search for "pandas set index"? http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html On Fri, May 13, 201

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, This is very weird. 55 145340.20 56 25.43 Name: 3, dtype: float64 It looks like two columns, but it shows one single object. Any clue? On Saturday, 14 May 2016, 4:15, David Shi wrote: Hello, Michael, I tried to discover the pro

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, I do not understand this. I tried list =df[3] it worked.  But, it does not behave like a list. list[0] nothinglist[1] a valuelist[2] nothing list[4] a value It behaves like a dictionary. On Saturday, 14 May 2016, 4:27, David Shi wrote: Hello, Michael, This is very weird.

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, I tried to discover the problem. df[0]   yields nothingdf[1]  yields nothingdf[2] yields nothing However, df[3] gives the following:sid -9223372036854775808 NaN 1 133738.70 4 295256.11 5 137733.09 6

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
What have code you tried? What error message are you receiving? On Fri, May 13, 2016, 5:54 PM David Shi wrote: > Hello, Michael, > > How to convert a float type column into an integer or label or string type? > > > On Friday, 13 May 2016, 22:02, Michael Selik > wrote: > > > To clarify that you'

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, How to convert a float type column into an integer or label or string type? On Friday, 13 May 2016, 22:02, Michael Selik wrote: To clarify that you're specifying the index as a label, use df.iloc     >>> df = pd.DataFrame({'X': range(4)}, index=list('abcd'))    >>> df   

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
To clarify that you're specifying the index as a label, use df.iloc >>> df = pd.DataFrame({'X': range(4)}, index=list('abcd')) >>> df X a 0 b 1 c 2 d 3 >>> df.loc['a'] X0 Name: a, dtype: int64 >>> df.iloc[0] X0 Name: a, dtype: int6

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Dear Michael, To avoid complication, I only groupby using one column. It is OK now.  But, how to refer to new row index?  How do I use floating index? Float64Index([ 1.0, 4.0, 5.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0,

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
Here's an example. >>> import pandas as pd >>> df = pd.DataFrame({'group': list('AB') * 2, 'data': range(4)}, index=list('wxyz')) >>> df data group w 0 A x 1 B y 2 A z 3 B >>> df = df.reset_index() >>> df index data

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, I changed groupby with one column. The index is different. Index([ u'AL',u'AR',u'AZ',u'CA',u'CO',u'CT',u'DC', u'DE',u'FL',u'GA',u'IA',u'ID',u'IL',u'IN', u'KS',u'KY',u'LA',u'MA',u'MD',u'ME',

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, I typed in df.index I got the followingMultiIndex(levels=[[1.0, 4.0, 5.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 44.0,

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Dear Michael, I have done a number of operation in between. Providing that information does not help you How to reset index after grouping and various operations is of interest. How to type in a command to find out its current dataframe? Regards. David On Friday, 13 May 2016, 20:58, Michael S

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Dear MIchael, I am very confused. Can you send me a link to a working example? Regards. David On Friday, 13 May 2016, 20:56, Michael Selik wrote: In order to preserve your index after the aggregation, you need to make sure it is considered a data column (via reset_index) and then choos

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
Just in case I misunderstood, why don't you make a little example of before and after the grouping? This mailing list does not accept attachments, so you'll have to make do with pasting a few rows of comma-separated or tab-separated values. On Fri, May 13, 2016 at 3:56 PM Michael Selik wrote: >

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
In order to preserve your index after the aggregation, you need to make sure it is considered a data column (via reset_index) and then choose how your aggregation will operate on that column. On Fri, May 13, 2016 at 3:29 PM David Shi wrote: > Hello, Michael, > > Why reset_index before grouping?

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael, Why reset_index before grouping? Regards. David On Friday, 13 May 2016, 17:57, Michael Selik wrote: On Fri, May 13, 2016 at 12:27 PM David Shi via Python-list wrote: I lost my indexes after grouping in Pandas. I managed to rest_index and got back the index column. B

Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
Hello, Michael,Thank you.  Yes, aster grouping I lost my indexing in both x, y directions. How to convert a row, and a column into indexes or labels? On Friday, 13 May 2016, 17:57, Michael Selik wrote: On Fri, May 13, 2016 at 12:27 PM David Shi via Python-list wrote: I lost my ind

Re: How to put back a number-based index

2016-05-13 Thread Michael Selik
On Fri, May 13, 2016 at 12:27 PM David Shi via Python-list < python-list@python.org> wrote: > I lost my indexes after grouping in Pandas. > I managed to rest_index and got back the index column. > But How can I get back a index row? > Was the grouping an aggregation? If so, the original indexes a

How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
I lost my indexes after grouping in Pandas. I managed to rest_index and got back the index column. But How can I get back a index row? Regards. David -- https://mail.python.org/mailman/listinfo/python-list