Any good explanations on pd.merge(df,df2, on=['Code', 'Region'])

2017-11-08 Thread David Shi via Python-list



 

 I am trying to gain a clear understanding on pd.merge(df,df2, on=['Code', 
'Region']).
Can anyone assist?
Regards,
David

   
-- 
https://mail.python.org/mailman/listinfo/python-list


Can some one give examples of how to use graph.label to get data values while dealing with N-Triples files?

2017-09-04 Thread David Shi via Python-list
How to used graph.label to get data values like 'Baddesley Clinton E04009816'?
 
 "Baddesley Clinton E04009816"@en 
. 
 "Live" 
. 
 "E04009816" .
Regards,
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How best to search and get values of label in N-Triples

2017-09-04 Thread David Shi via Python-list
I have a parsed N-Triples file, having many items like the following.
 
 "Baddesley Clinton E04009816"@en 
. 
 "Live" 
. 
 "E04009816" .

How best to search and get values of label?
Regards,
David


-- 
https://mail.python.org/mailman/listinfo/python-list


Looking for Python examples for querying, selecting items in N-Triples

2017-09-04 Thread David Shi via Python-list
I found this is very confusing.
I will appreciate if simple examples are given.
Regards,
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Select data in N-Triples

2017-09-01 Thread David Shi via Python-list

in a N-Triples file, there are a lot lines like the following:
 
 "Baginton E04009817"@en 
. 
 "Live" 
. 
 "E04009817" .
What I am interested is to find all lines contains something like "Baginton 
E04009817".
Then, put the name and code into corresponding cells in 2 columns.
Maybe, the solution is to find ways to select those lines having 
rdf-schema#label
Is there a good example?
Regards,
David
-- 
https://mail.python.org/mailman/listinfo/python-list


rdflib, N-Triples and Pandas

2017-09-01 Thread David Shi via Python-list
How best to use rdflib to parse N-Triples files and turn them into Pandas 
tables?
Looking forward to hearing from you.
Regards,
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Is there tested Python code for parsing N-Triples?

2017-08-31 Thread David Shi via Python-list
Is there tested Python code for parsing N-Triples?
Looking forward to hearing from you.
Regards,
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to make sure the result of Pandas.to_csv does not have non-ASCII code?

2017-05-31 Thread David Shi via Python-list
How to make sure the result of Pandas.to_csv does not have non-ASCII code?

Regards,
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Pressing dot and show sub command in IPython

2017-04-18 Thread David Shi via Python-list
Hi, Matt,
How to make IPython work more interactively?
As I remember, pressing dot and sub command shows up suggestively in IPython.
But, now, after re-installing IPython notebook, it does not do so any more.
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to do pd.read_csv with consecutive spaces or semi-colon as delimiters?

2017-04-18 Thread David Shi via Python-list


Any way to do that?
The link to a sample dataset is as follows:
http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22=sequence_release=text
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2017-04-13 Thread David Shi via Python-list


Which VCF reader has been well tested and proven to be robust?
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2017-04-13 Thread David Shi via Python-list
13.1. csv — CSV File Reading and Writing — Python 2.7.13 documentation





| 
|  | 
13.1. csv — CSV File Reading and Writing — Python 2.7.13 documentation
 |  |

 |



I am trying to parse this text file into a table.
How to use consecutive 3 spaces to work as delimiter with csv.reader?

Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Reading structured text file (non-CSV) into Pandas Dataframe

2017-04-13 Thread David Shi via Python-list
http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22=sequence_release=text
The above is a web link to a structured text file.  It is not a CSV.
How can this text file be read into a Pandas Dataframe, so that further 
processing can be made?
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Read a text file into a Pandas DataFrame Table

2017-04-13 Thread David Shi via Python-list
Dear All,
Can anyone help to read a text file into a Pandas DataFrame Table?
Please see the link below.
http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22=sequence_release=text

Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to pd.read_csv into a DataFrame with multiple seperators?

2017-04-12 Thread David Shi via Python-list
Have a look at this example.
http://www.ebi.ac.uk/ena/data/warehouse/search?query=%22geo_circ(-0.587,-90.5713,170)%22=sequence_release=text


How to pd.read_csv into a DataFrame with multiple seperators?

Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


XML tree to a pandas dataframe

2017-04-12 Thread David Shi via Python-list
What is the best way to convert XML document into a pandas dataframe?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Pound sign problem

2017-04-10 Thread David Shi via Python-list
In the data set, pound sign escape appears:
u'price_currency': u'\xa3', u'price_formatted': u'\xa3525,000',
When using table.to_csv after importing pandas as pd, an error message persists 
as follows:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 0: 
ordinal not in range(128)

Can anyone help?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


A Python solution for turning a web page into Pandas DataFrame table

2017-04-07 Thread David Shi via Python-list


Is there a Python solution for turning a web page into Pandas DataFrame table?
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2017-04-07 Thread David Shi via Python-list


I was using IPython notebooks.  All the sudden, it asks for password or token.
I did not set any password or token.
How do I get back to use my IPython notebooks?
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread David Shi via Python-list
Hi, Skip,
This is something very different.
New thinking and methods are needed.
Try to click on the following link
European Commission : CORDIS : Search : Results page


| 
| 
| 
|  |  |

 |

 |
| 
|  | 
European Commission : CORDIS : Search : Results page
European Commission |  |

 |

 |



Is there a way to capture the file?
Regards.
David
 

On Wednesday, 5 April 2017, 17:19, Skip Montanaro 
<skip.montan...@gmail.com> wrote:
 

 I'm not positive, but try passing response to read_csv() instead of reading 
the bytes yourself.
Skip
On Apr 5, 2017 10:38 AM, "David Shi via Python-list" <python-list@python.org> 
wrote:



I tried the following codes:
import urllib2response = urllib2.urlopen('http:// cordis.europa.eu/search/ 
result_en?q=uk=csv') myCSV = response.read()
myFile = pd.read_csv(myCSV)

but, it did not work well.
Can any one help?
Regards.
David
--
https://mail.python.org/ mailman/listinfo/python-list



   
-- 
https://mail.python.org/mailman/listinfo/python-list


How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread David Shi via Python-list


I tried the following codes:
import urllib2response = 
urllib2.urlopen('http://cordis.europa.eu/search/result_en?q=uk=csv')myCSV
 = response.read()
myFile = pd.read_csv(myCSV)

but, it did not work well.
Can any one help?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to make use of .egg files?

2017-04-05 Thread David Shi via Python-list
Can anyone explain please.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to search out all Zip codes and replace with the first 2 digits, in a Pandas dataframe, with the use of regex?

2017-03-20 Thread David Shi via Python-list
Hi, there,
Can anyone help?
How to search out all Zip codes and replace with the first 2 digits, in a 
Pandas dataframe, with the use of regex?

For instance, a ZIP code 33132 was found and replaced with 33.
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Two constructive reviewers sought

2016-07-27 Thread David Shi via Python-list
To promote the use of Python and formalise Python approach, I decided to 
publish a paper.
I used geodata as a showcase.
Geodata lies in the heart of geographical information science.  The management 
and processing of such data is of great importance.

I got an email from International Journal of Information Management.
I was asked to suggest two reviewers for the following article.
"Key solutions for automated data linkage, processing and generating output for 
big data analytics over the Internet".

Nitrogen input from fertilizer use data was used as a showcase.
If you like to be one of reviewers, please email drshishaozh...@gmail.com with 
your full contact details.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Live installation of Pandas for Windows 64

2016-06-27 Thread David Shi via Python-list
Is there a live installation of Pandas for Windows 64?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


JSON to Pandas data frame

2016-06-25 Thread David Shi via Python-list
How to convert a JSON object into a Pandas data frame?
I know that for XML, there are XML parsers.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to reset IPython notebook file association

2016-06-25 Thread David Shi via Python-list
I use IPython Notebook to do Python programming.
I used "Open with" and set it with Google Chrome.  Then, my IPython notebook 
does not load properly.
How can I reset IPython notebook file association, so that I can use it again?
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Which one is the best JSON parser?

2016-06-23 Thread David Shi via Python-list
Can any one tell me?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Which one is the best XML-parser?

2016-06-23 Thread David Shi via Python-list
Which one is the best XML-parser?
Can any one tell me?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Pandas to CSV and .dbf

2016-06-23 Thread David Shi via Python-list
Has anyone tested on Pandas to CSV and .dbf lately?
I am looking for proven, tested examples to output Panda Data Frame to CSV and 
dbf files.
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Pandas GroupBy does not behave consistently

2016-05-15 Thread David Shi via Python-list
 to accomplish 
in detail -- what variables you started with, what transformations you want to 
do, and what variables you hope to have when finished.
On Fri, May 13, 2016 at 4:36 PM David Shi <davidg...@yahoo.co.uk> wrote:

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',u'MI',
  u'MN',u'MO',u'MS',u'MT',u'NC',u'ND',u'NE',
  u'NH',u'NJ',u'NM',u'NV',u'NY',u'OH',u'OK',
  u'OR',u'PA',u'RI',u'SC',u'SD', u'State',u'TN',
  u'TX',u'UT',u'VA',u'VT',u'WA',u'WI',u'WV',
  u'WY'],
  dtype='object', name=0)
How to use this index?
Regards.
David 

On Friday, 13 May 2016, 21:19, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 53.0, 
54.0, 55.0, 56.0], [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', u'MI', u'MN', u'MO', u'MS', u'MT', u'NC', u'ND', u'NE', u'NH', u'NJ', 
u'NM', u'NV', u'NY', u'OH', u'OK', u'OR', u'PA', u'RI', u'SC', u'SD', u'State', 
u'TN', u'TX', u'UT', u'VA', u'VT', u'WA', u'WI', u'WV', u'WY']],
   labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [0, 2, 1, 3, 4, 5, 7, 6, 8, 9, 
11, 12, 13, 10, 14, 15, 16, 19, 18, 17, 20, 21, 23, 22, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   


   


   


   


   



   


  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to put back a number-based index

2016-05-14 Thread David Shi via Python-list
, 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', u'MI', u'MN', u'MO', u'MS', u'MT', u'NC', u'ND', u'NE', u'NH', u'NJ', 
u'NM', u'NV', u'NY', u'OH', u'OK', u'OR', u'PA', u'RI', u'SC', u'SD', u'State', 
u'TN', u'TX', u'UT', u'VA', u'VT', u'WA', u'WI', u'WV', u'WY']],
   labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [0, 2, 1, 3, 4, 5, 7, 6, 8, 9, 
11, 12, 13, 10, 14, 15, 16, 19, 18, 17, 20, 21, 23, 22, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   


   


   


   


  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to put back a number-based index

2016-05-14 Thread David Shi via Python-list
, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   


   


   


   

  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to put back a number-based index

2016-05-14 Thread David Shi via Python-list
  labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [0, 2, 1, 3, 4, 5, 7, 6, 8, 9, 
11, 12, 13, 10, 14, 15, 16, 19, 18, 17, 20, 21, 23, 22, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   


   


   


   

   

  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to put back a number-based index

2016-05-14 Thread David Shi via Python-list
tion 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   


   


   


  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to put back a number-based index

2016-05-13 Thread David Shi via Python-list
ur 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   


   


  
-- 
https://mail.python.org/mailman/listinfo/python-list


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, 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, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0,
  51.0, 53.0, 54.0, 55.0, 56.0],
 dtype='float64', name=u'StateFIPS')
Regards.
David 

On Friday, 13 May 2016, 21:43, Michael Selik <michael.se...@gmail.com> 
wrote:
 

 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 group    0     w     0     A    1   
  x     1     B    2     y     2     A    3     z     3     B    >>> 
df.groupby('group').max()          index  data    group    A         y     2    
B         z     3
If that doesn't help, you'll need to explain what you're trying to accomplish 
in detail -- what variables you started with, what transformations you want to 
do, and what variables you hope to have when finished.
On Fri, May 13, 2016 at 4:36 PM David Shi <davidg...@yahoo.co.uk> wrote:

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',u'MI',
  u'MN',u'MO',u'MS',u'MT',u'NC',u'ND',u'NE',
  u'NH',u'NJ',u'NM',u'NV',u'NY',u'OH',u'OK',
  u'OR',u'PA',u'RI',u'SC',u'SD', u'State',u'TN',
  u'TX',u'UT',u'VA',u'VT',u'WA',u'WI',u'WV',
  u'WY'],
  dtype='object', name=0)
How to use this index?
Regards.
David 

On Friday, 13 May 2016, 21:19, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 53.0, 
54.0, 55.0, 56.0], [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', u'MI', u'MN', u'MO', u'MS', u'MT', u'NC', u'ND', u'NE', u'NH', u'NJ', 
u'NM', u'NV', u'NY', u'OH', u'OK', u'OR', u'PA', u'RI', u'SC', u'SD', u'State', 
u'TN', u'TX', u'UT', u'VA', u'VT', u'WA', u'WI', u'WV', u'WY']],
   labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [0, 2, 1, 3, 4, 5, 7, 6, 8, 9, 
11, 12, 13, 10, 14, 15, 16, 19, 18, 17, 20, 21, 23, 22, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are mea

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',u'MI',
  u'MN',u'MO',u'MS',u'MT',u'NC',u'ND',u'NE',
  u'NH',u'NJ',u'NM',u'NV',u'NY',u'OH',u'OK',
  u'OR',u'PA',u'RI',u'SC',u'SD', u'State',u'TN',
  u'TX',u'UT',u'VA',u'VT',u'WA',u'WI',u'WV',
  u'WY'],
  dtype='object', name=0)
How to use this index?
Regards.
David 

On Friday, 13 May 2016, 21:19, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 53.0, 
54.0, 55.0, 56.0], [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', u'MI', u'MN', u'MO', u'MS', u'MT', u'NC', u'ND', u'NE', u'NH', u'NJ', 
u'NM', u'NV', u'NY', u'OH', u'OK', u'OR', u'PA', u'RI', u'SC', u'SD', u'State', 
u'TN', u'TX', u'UT', u'VA', u'VT', u'WA', u'WI', u'WV', u'WY']],
   labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [0, 2, 1, 3, 4, 5, 7, 6, 8, 9, 
11, 12, 13, 10, 14, 15, 16, 19, 18, 17, 20, 21, 23, 22, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   

   
-- 
https://mail.python.org/mailman/listinfo/python-list


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, 45.0, 46.0, 47.0, 48.0, 49.0, 50.0, 51.0, 53.0, 
54.0, 55.0, 56.0], [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', u'MI', u'MN', u'MO', u'MS', u'MT', u'NC', u'ND', u'NE', u'NH', u'NJ', 
u'NM', u'NV', u'NY', u'OH', u'OK', u'OR', u'PA', u'RI', u'SC', u'SD', u'State', 
u'TN', u'TX', u'UT', u'VA', u'VT', u'WA', u'WI', u'WV', u'WY']],
   labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [0, 2, 1, 3, 4, 5, 7, 6, 8, 9, 
11, 12, 13, 10, 14, 15, 16, 19, 18, 17, 20, 21, 23, 22, 24, 27, 31, 28, 29, 30, 
32, 25, 26, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 45, 44, 46, 48, 47, 49]],
   names=[u'StateFIPS', 0])Regards.
David 

On Friday, 13 May 2016, 21:11, David Shi <davidg...@yahoo.co.uk> wrote:
 

 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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   

   
-- 
https://mail.python.org/mailman/listinfo/python-list


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 Selik <michael.se...@gmail.com> 
wrote:
 

 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 <michael.se...@gmail.com> 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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 



   
-- 
https://mail.python.org/mailman/listinfo/python-list


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 <michael.se...@gmail.com> 
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 choose how your 
aggregation will operate on that column.
On Fri, May 13, 2016 at 3:29 PM David Shi <davidg...@yahoo.co.uk> wrote:

Hello, Michael,
Why reset_index before grouping?
Regards.
David 

  On Friday, 13 May 2016, 17:57, Michael Selik <michael.se...@gmail.com> wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

 


   
-- 
https://mail.python.org/mailman/listinfo/python-list


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 <michael.se...@gmail.com> 
wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

   
-- 
https://mail.python.org/mailman/listinfo/python-list


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 <michael.se...@gmail.com> 
wrote:
 

 

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 are meaningless. 
What you could do is reset_index before the grouping and when you aggregate 
decide how to handle the formerly-known-as-index column (min, max, mean, ?).

  
-- 
https://mail.python.org/mailman/listinfo/python-list


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


How to call a Python Class?

2016-05-03 Thread David Shi via Python-list
I found a Python class within an Open Source software.
I would like to use it in my own Python script.
I tried to import it, but I got following message.
from intersection import *Traceback (most recent call last):  File 
"", line 1, in     from intersection import *ImportError: 
bad magic number in 'intersection': b'\x03\xf3\r\n'
Can any one help?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


How to fill in abbreviation in one column based on state name in another column?

2016-05-01 Thread David Shi via Python-list
Hello, I am back.  Thank you very much for your positive response.
I am trying to use Pandas apply to execute a lookup function, so that we can 
put abbreviation in a new column, in accordance to a state name in another 
column.
Does anyone knows how to make this to work?
Regards.DavidLook up functionstate_to_code = {"VERMONT": "VT", "GEORGIA": "GA", 
"IOWA": "IA"}#table['moa_state_name'] = map(lambda x: x.upper(), 
table['moa_state_name'])def convert_state(row):    abbrev1 =  
state_to_code(table['moa_state_name']) #'aatest'    if abbrev1:         return 
abbrev1 ##state_to_code[abbrev[0]]    return np.nan#print 
convert_state(table['moa_state_name'])
table.insert(0, "abbrev", np.nan)
table['abbrev'] = table.apply(convert_state, axis=1)print 
state_to_code['ARKANSAS']
-- 
https://mail.python.org/mailman/listinfo/python-list


How to fill in abbreviation in one column based on state name in another column?

2016-04-30 Thread David Shi via Python-list
I am trying to use apply to execute a lookup function, so that we can put 
abbreviation in a new column, in accordance to a state name in another column.
Does anyone knows how to make this to work?
Regards.
David
state_to_code = {"VERMONT": "VT", "GEORGIA": "GA", "IOWA": "IA", "Armed Forces 
Pacific": "AP", "GUAM": "GU",                 "KANSAS": "KS", "FLORIDA": "FL", 
"AMERICAN SAMOA": "AS", "NORTH CAROLINA": "NC", "HAWAII": "HI",                 
"NEW YORK": "NY", "CALIFORNIA": "CA", "ALABAMA": "AL", "IDAHO": "ID", 
"FEDERATED STATES OF MICRONESIA": "FM",                 "Armed Forces 
Americas": "AA", "DELAWARE": "DE", "ALASKA": "AK", "ILLINOIS": "IL",            
     "Armed Forces Africa": "AE", "SOUTH DAKOTA": "SD", "CONNECTICUT": "CT", 
"MONTANA": "MT", "MASSACHUSETTS": "MA",                 "PUERTO RICO": "PR", 
"Armed Forces Canada": "AE", "NEW HAMPSHIRE": "NH", "MARYLAND": "MD", "NEW 
MEXICO": "NM",                 "MISSISSIPPI": "MS", "TENNESSEE": "TN", "PALAU": 
"PW", "COLORADO": "CO", "Armed Forces Middle East": "AE",                 "NEW 
JERSEY": "NJ", "UTAH": "UT", "MICHIGAN": "MI", "WEST VIRGINIA": "WV", 
"WASHINGTON": "WA",                 "MINNESOTA": "MN", "OREGON": "OR", 
"VIRGINIA": "VA", "VIRGIN ISLANDS": "VI", "MARSHALL ISLANDS": "MH",             
    "WYOMING": "WY", "OHIO": "OH", "SOUTH CAROLINA": "SC", "INDIANA": "IN", 
"NEVADA": "NV", "LOUISIANA": "LA",                 "NORTHERN MARIANA ISLANDS": 
"MP", "NEBRASKA": "NE", "ARIZONA": "AZ", "WISCONSIN": "WI", "NORTH DAKOTA": 
"ND",                 "Armed Forces Europe": "AE", "PENNSYLVANIA": "PA", 
"OKLAHOMA": "OK", "KENTUCKY": "KY", "RHODE ISLAND": "RI",                 
"DISTRICT OF COLUMBIA": "DC", "ARKANSAS": "AR", "MISSOURI": "MO", "TEXAS": 
"TX", "MAINE": "ME"}
#table['moa_state_name'] = map(lambda x: x.upper(), table['moa_state_name'])def 
convert_state(row):    abbrev1 =  state_to_code(table['moa_state_name']) 
#'aatest'    if abbrev1:         return abbrev1 ##state_to_code[abbrev[0]]    
return np.nan#print convert_state(table['moa_state_name'])
table.insert(0, "abbrev", np.nan)table['abbrev'] = table.apply(convert_state, 
axis=1)
print state_to_code['ARKANSAS']
-- 
https://mail.python.org/mailman/listinfo/python-list


Pivot table of Pandas

2016-04-28 Thread David Shi via Python-list




 Hello, Matt,
Please see the web link.Pandas Pivot Table Explained

|   |
|   |   |   |   |   |
| Pandas Pivot Table ExplainedExplanation of pandas pivot_table function. |
|  |
| View on pbpython.com | Preview by Yahoo |
|  |
|   |


Debra and Fred have their own groups.
How to split the pivot table into separate tables?
What types of objects are these pivot tables?
How to access the "manager" column?
the pivot table is interesting to users, but it is very different from 
databases which we normally know.
Looking forward to hearing from you.
Regards.
David

  
-- 
https://mail.python.org/mailman/listinfo/python-list


Simplest way to locate a string in a column and get the value on the same row in another column

2016-04-28 Thread David Shi via Python-list




 What is the simplest way to locate a string in a column and get the value on 
the same row in another column ?
1  a2  b3  c
Locate b and obtain 2 in a table.
Looking forward to hearing from you.
Regards.
David

  
-- 
https://mail.python.org/mailman/listinfo/python-list


ONE CLICK REST API

2016-04-04 Thread David Shi via Python-list
Eclipse has got one click app for creating REST services.
What is it equivalent in Python?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Which plugin allows quick creation of secure REST services?

2016-03-31 Thread David Shi via Python-list
Hello, 
Which plugin allows quick creation of secure REST services?  so that Python 
scripts can be attached to it.

Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


IPython and Jupyter

2016-03-29 Thread David Shi via Python-list
Ipython-4.1.2
I thought that I installed Ipython.
I typed in ipython notebook.
But a WARNING came up, saying Subcommand 'ipython notebook is deprecated and 
will be removed in future versions.
Then Jupyter turned up.
How can I make available both Ipython notebook and Jupyter?, so that I can 
switch between the twowhenever required.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Simple, fast responsive, secure way of creating REST services

2016-03-29 Thread David Shi via Python-list
Hello, Justin,
What you said is very interesting and useful.
I just wonder whether there are much simpler alternatives for fast, responsive, 
secure REST services.  Python at server-side.  It provides REST services.  Data 
exchange with the web--page.  Formatted XML or Json.
Ideally, it uses the least code.
Perhaps, some folks in this group have made great achievement for doing so, and 
would like to share with us.   Or, any excellent literature describes this?  I 
like articles which give insight into the nitty-gritty.
Looking forward to hearing from you.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Which are best, well-tested ways to create REST services, with Json, in Python?

2016-03-28 Thread David Shi via Python-list
Has anyone done a recent reviews of creating REST services, in Python?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list