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


How to get values for skos/note, skos/notation and label in N-Triples

2017-09-05 Thread David Shi via Python-list
 "Baginton E04009817"@en 
. 
 "Live" 
. 
 "E04009817" .

Are there any hello world examples?
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&result=sequence_release&display=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&result=sequence_release&display=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&result=sequence_release&display=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&result=sequence_release&display=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 
 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"  
wrote:



I tried the following codes:
import urllib2response = urllib2.urlopen('http:// cordis.europa.eu/search/ 
result_en?q=uk&format=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&format=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
Hello, Michael,
Pandas GroupBy does not behave consistently.
Last time, when we had conversation, I used grouby.  It works well.
Now, I thought to re-write the program, so that I can end up with a clean 
script.
But, the problem is that a lot of columns are missing after groupby application.
Any idea?
Regards.
David 

On Saturday, 14 May 2016, 17:00, Michael Selik  
wrote:
 

 This StackOverflow question was the first search result when I Googled for 
"Python why is there a little 
u"http://stackoverflow.com/questions/11279331/what-does-the-u-symbol-mean-in-front-of-string-values
On Sat, May 14, 2016, 11:40 AM David Shi  wrote:

Hello, Michael,
Why there is a little u ?  u'ID',?
Why can be done to it?  How to handle such objects?
Can it be turn into list easily?
Regards.
David 

On Saturday, 14 May 2016, 15:34, Michael Selik  
wrote:
 

 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 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 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 only get shown as an object.  Are there anything to be typed 
in Python, to reveal objects.
Regards.
David 

On Saturday, 14 May 2016, 4:30, 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 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, 2016 at 11:18 PM David Shi  wrote:

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  409413.58
 8  269600.97
 9   12852.94
Can we split this back to normal?  or turn it into a dictionary, so that I can 
put values back properly.
I like to use sid as index, some way.
Regards.
David 

On Friday, 13 May 2016, 22:58, Michael Selik  
wrote:
 

 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 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']    X    0    Name: a, 
dtype: int64    >>> df.iloc[0]    X    0    Name: a, dtype: int64
On Fri, May 13, 2016 at 4:54 PM David Shi  wrote:

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  
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  wrote:

Hello, Michae

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 only get shown as an object.  Are there anything to be typed 
in Python, to reveal objects.
Regards.
David 

On Saturday, 14 May 2016, 4:30, 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 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, 2016 at 11:18 PM David Shi  wrote:

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  409413.58
 8  269600.97
 9   12852.94
Can we split this back to normal?  or turn it into a dictionary, so that I can 
put values back properly.
I like to use sid as index, some way.
Regards.
David 

On Friday, 13 May 2016, 22:58, Michael Selik  
wrote:
 

 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 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']    X    0    Name: a, 
dtype: int64    >>> df.iloc[0]    X    0    Name: a, dtype: int64
On Fri, May 13, 2016 at 4:54 PM David Shi  wrote:

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  
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  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  wrote:
 

 Hello, Michael,
I typed in df.index
I got th

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 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  409413.58
 8  269600.97
 9   12852.94
Can we split this back to normal?  or turn it into a dictionary, so that I can 
put values back properly.
I like to use sid as index, some way.
Regards.
David 

On Friday, 13 May 2016, 22:58, Michael Selik  
wrote:
 

 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 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']    X    0    Name: a, 
dtype: int64    >>> df.iloc[0]    X    0    Name: a, dtype: int64
On Fri, May 13, 2016 at 4:54 PM David Shi  wrote:

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  
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  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  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&#x

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.
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 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  409413.58
 8  269600.97
 9   12852.94
Can we split this back to normal?  or turn it into a dictionary, so that I can 
put values back properly.
I like to use sid as index, some way.
Regards.
David 

On Friday, 13 May 2016, 22:58, Michael Selik  
wrote:
 

 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 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']    X    0    Name: a, 
dtype: int64    >>> df.iloc[0]    X    0    Name: a, dtype: int64
On Fri, May 13, 2016 at 4:54 PM David Shi  wrote:

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

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  409413.58
 8  269600.97
 9   12852.94
Can we split this back to normal?  or turn it into a dictionary, so that I can 
put values back properly.
I like to use sid as index, some way.
Regards.
David 

On Friday, 13 May 2016, 22:58, Michael Selik  
wrote:
 

 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 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']    X    0    Name: a, 
dtype: int64    >>> df.iloc[0]    X    0    Name: a, dtype: int64
On Fri, May 13, 2016 at 4:54 PM David Shi  wrote:

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  
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  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  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'

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       
X    a  0    b  1    c  2    d  3    >>> df.loc['a']    X    0    Name: a, 
dtype: int64    >>> df.iloc[0]    X    0    Name: a, dtype: int64
On Fri, May 13, 2016 at 4:54 PM David Shi  wrote:

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  
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  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  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, 4

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  
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  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  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  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  
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  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  wrote:

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.
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 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  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  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  
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  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  wrote:

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.
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  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  
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  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  wrote:

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.
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  
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  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  wrote:

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.
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  
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  wrote:

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.
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  
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.
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  
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.
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-03 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


Re: Python-list Digest, Vol 108, Issue 98

2012-09-12 Thread David Shi
Hi, 

Where do I find ArcPy.py?

It seems that the link disappeared.

Regards.

David-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for download link for ArcPY

2012-09-08 Thread David Shi
Hi, All,

Can anyone send me the link for downloading ArcPY?

I came across it before, but can not find it anymore.

Regards.

David-- 
http://mail.python.org/mailman/listinfo/python-list


Where is the lastest step by step guide to compile Python into an executable?

2012-06-07 Thread David Shi
Hi, folks.

Where is the lastest step by step guide to compile Python into an executable?

Regards.

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Has theHas Python community got Alan Saalfeld et al's algorithm and source code implementation

2012-06-05 Thread David Shi
Dear Python community friends,

I wonder whether there is such a Python implementation available.


Alan Saalfeld et al's algorithm and source codes.

http://books.google.ie/books/about/A_Modified_Douglas_Peucker_Simplificatio.html?id=gbQjywAACAAJ&redir_esc=y

In Zhiyuan Zhao and Alan Saafeld's paper, LINEAR-TIME SLEEVE-FITTING POLYLINE
SIMPLIFICATION ALGORITHMS
Zhiyuan Zhao, Alan Saalfeld

They mentioned "
The results of those
experiments and more information on the algorithms themselves, including
complete working code, are available to the interested reader at the World Wide
Web site http://ra.cfm.ohio-state.edu/grad/zhao/algorithms/linesimp.html.";

However, this site is no longer alive.

If anyone knows, please let me know.   davidg...@yahoo.co.uk

Regards.

David-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is the latest step by step guide to use Jython to compilePython into Java?

2012-06-04 Thread David Shi
Hello, Mohan,

Did you test it?  I am using Windows.  Where are the exact steps for compiling 
in DOS?

Once .class or jar files created, how to use these files?

Could you enlighten me with tested/proven step by step instructions?

Regards.

David




 From: "Narayanaswamy, Mohan" 
To: David Shi  
Cc: python-list@python.org 
Sent: Monday, 4 June 2012, 16:38
Subject: RE: Where is the latest step by step guide to use Jython to 
compilePython into Java?
 

David,
 
Thanks for the link, here that compilation steps won’t produce  java code, but 
it could create .class file (or jar).
 
Regards
Mohan
 
From:David Shi [mailto:davidg...@yahoo.co.uk] 
Sent: Monday, June 04, 2012 11:35 PM
To: Narayanaswamy, Mohan
Cc: python-list@python.org
Subject: Re: Where is the latest step by step guide to use Jython to 
compilePython into Java?
 
Mohan,
 
Please see the following link as an example.
http://www.ssec.wisc.edu/~tomw/visadtutor/compile.html
 
I just can not make any success with some of these instructions.
Compiling your Python code with jythonc
I do not know whether I downloaded a wrong version of Jythonc?   Or, got 
mismatched software or instructions.
 
Please provide assistance, by providing the tested software and instructions.
 
Regards.
 
David
 



From:"Narayanaswamy, Mohan" 
To: David Shi  
Cc: python-list@python.org 
Sent: Monday, 4 June 2012, 15:56
Subject: RE: Where is the latest step by step guide to use Jython to 
compilePython into Java?
 
David,
 
As per my knowledge, You can’t find steps to convert python into java anywhere.
 
1)  I am not expert in python, but familiar with Java. Python by default 
uses python-vm and converts into byte code, which is not compatible with JVM 
byte-code, Jython/Jruby/Jxxx are supporting languages on top of JVM. Jython is 
executing python on top of JVM, by doing that, we can make use of java library 
inside python and/or vice versa. 
2)  Python is dynanmic programming (but strongly typed), java is 
static-typed language.  Currently it is not possible to convert python into 
java, since python types are dynamically identified, not identified during 
compilation.
 
Regards
Mohan
 
From:python-list-bounces+mohan.narayanaswamy-2=sc@python.org 
[mailto:python-list-bounces+mohan.narayanaswamy-2=sc@python.org] On Behalf 
Of David Shi
Sent: Monday, June 04, 2012 10:36 PM
To: python-list@python.org
Subject: Where is the latest step by step guide to use Jython to compilePython 
into Java?
 
Hello,
 
Where is the latest step by step guide to use Jython to compile Python into 
Java?
 
I found that it was very confusing by reading not updated text.
 
Please help.
 
Regards.
 
David

This email and any attachments are confidential and may also be privileged. If 
you are not the addressee, do not disclose, copy, circulate or in any other way 
use or rely on the information contained in this email or any attachments. If 
received in error, notify the sender immediately and delete this email and any 
attachments from your system. Emails cannot be guaranteed to be secure or error 
free as the message and any attachments could be intercepted, corrupted, lost, 
delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do 
not accept liability for damage caused by this email or any attachments and may 
monitor email traffic.

Standard Chartered PLC is incorporated in England with limited liability under 
company number 966425 and has its registered office at 1 Aldermanbury Square, 
London, EC2V 7SB.

Standard Chartered Bank ("SCB") is incorporated in England with limited 
liability by Royal Charter 1853, under reference ZC18. The Principal Office of 
SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the 
United Kingdom, SCB is authorised and regulated by the Financial Services 
Authority under FSA register number 114276.

If you are receiving this email from SCB outside the UK, please click 
http://www.standardchartered.com/global/email_disclaimer.html to refer to the 
information on other jurisdictions.
 
This email and any attachments are confidential and may also be privileged.  If 
you are not the addressee, do not disclose, copy, circulate or in any other way 
use or rely on the information contained in this email or any attachments.  If 
received in error, notify the sender immediately and delete this email and any 
attachments from your system.  Emails cannot be guaranteed to be secure or 
error free as the message and any attachments could be intercepted, corrupted, 
lost, delayed, incomplete or amended.  Standard Chartered PLC and its 
subsidiaries do not accept liability for damage caused by this email or any 
attachments and may monitor email traffic.

Standard Chartered PLC is incorporated in England with limited liability under 
company number 966425 and has its registered office at 1 Aldermanbury Square, 
London, EC2V

Re: Where is the latest step by step guide to use Jython to compilePython into Java?

2012-06-04 Thread David Shi
Mohan,

Please see the following link as an example.
http://www.ssec.wisc.edu/~tomw/visadtutor/compile.html

I just can not make any success with some of these instructions.
Compiling your Python code with jythonc
I do not know whether I downloaded a wrong version of Jythonc?   Or, got 
mismatched software or instructions.

Please provide assistance, by providing the tested software and instructions.

Regards.

David




 From: "Narayanaswamy, Mohan" 
To: David Shi  
Cc: python-list@python.org 
Sent: Monday, 4 June 2012, 15:56
Subject: RE: Where is the latest step by step guide to use Jython to 
compilePython into Java?
 

David,
 
As per my knowledge, You can’t find steps to convert python into java anywhere.
 
1)  I am not expert in python, but familiar with Java. Python by default 
uses python-vm and converts into byte code, which is not compatible with JVM 
byte-code, Jython/Jruby/Jxxx are supporting languages on top of JVM. Jython is 
executing python on top of JVM, by doing that, we can make use of java library 
inside python and/or vice versa. 
2)  Python is dynanmic programming (but strongly typed), java is 
static-typed language.  Currently it is not possible to convert python into 
java, since python types are dynamically identified, not identified during 
compilation.
 
Regards
Mohan
 
From:python-list-bounces+mohan.narayanaswamy-2=sc@python.org 
[mailto:python-list-bounces+mohan.narayanaswamy-2=sc@python.org] On Behalf 
Of David Shi
Sent: Monday, June 04, 2012 10:36 PM
To: python-list@python.org
Subject: Where is the latest step by step guide to use Jython to compilePython 
into Java?
 
Hello,
 
Where is the latest step by step guide to use Jython to compile Python into 
Java?
 
I found that it was very confusing by reading not updated text.
 
Please help.
 
Regards.
 
David
This email and any attachments are confidential and may also be privileged.  If 
you are not the addressee, do not disclose, copy, circulate or in any other way 
use or rely on the information contained in this email or any attachments.  If 
received in error, notify the sender immediately and delete this email and any 
attachments from your system.  Emails cannot be guaranteed to be secure or 
error free as the message and any attachments could be intercepted, corrupted, 
lost, delayed, incomplete or amended.  Standard Chartered PLC and its 
subsidiaries do not accept liability for damage caused by this email or any 
attachments and may monitor email traffic.

Standard Chartered PLC is incorporated in England with limited liability under 
company number 966425 and has its registered office at 1 Aldermanbury Square, 
London, EC2V 7SB.

Standard Chartered Bank ("SCB") is incorporated in England with limited 
liability by Royal Charter 1853, under reference ZC18.  The Principal Office of 
SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the 
United Kingdom, SCB is authorised and regulated by the Financial Services 
Authority under FSA register number 114276.

If you are receiving this email from SCB outside the UK, please click 
http://www.standardchartered.com/global/email_disclaimer.html to refer to the 
information on other jurisdictions.-- 
http://mail.python.org/mailman/listinfo/python-list


Where is the latest step by step guide to use Jython to compile Python into Java?

2012-06-04 Thread David Shi
Hello,

Where is the latest step by step guide to use Jython to compile Python into 
Java?

I found that it was very confusing by reading not updated text.

Please help.

Regards.

David
-- 
http://mail.python.org/mailman/listinfo/python-list


While stack:

2012-06-01 Thread David Shi
Can any one clarify what "while stack:" mean?

Regards,

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for Python script for Vector Map simplification, preserving shape and topology

2012-05-17 Thread David Shi
Dear All,

I am looking for Python script for Vector Map simplification, preserving shape 
and topology.

Please get in touch with davidg...@yahoo.co.uk    


Regards.

David
-- 
http://mail.python.org/mailman/listinfo/python-list


How to call and execute C code in Python?

2012-05-15 Thread David Shi
How to call and execute C code in Python?

Is there any publication/documentation for this?   For the worst scenario, how 
many ways are there to call and execute C codes, in Python. 


For instance, having got hold some C codes, attempting to use Python to call 
and execute C codes.  I.e.  Python, as the integrating language.

Can anyone send publications/instructions to davidg...@yahoo.co.uk?

All the best to everyone!

Regards.

David




 From: "python-list-requ...@python.org" 
To: python-list@python.org 
Sent: Sunday, 13 May 2012, 19:14
Subject: Python-list Digest, Vol 104, Issue 67
 
- Forwarded Message -

Send Python-list mailing list submissions to
    python-list@python.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
    python-list-requ...@python.org

You can reach the person managing the list at
    python-list-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."

Today's Topics:

   1. Re: Good data structure for finding date intervals including
      a given    date (Arnaud Delobelle)
   2. Re: Good data structure for finding date intervals including
      a given    date (Emile van Sebille)
   3. Re: How to call and execute C code in Python? (Chris Angelico)
   4. Re: How to call and execute C code in Python? (Stefan Behnel)
   5. Re: How to call and execute C code in Python? (Mark Lawrence)
   6. Re: How to call and execute C code in Python? (Mark Lawrence)
   7. Re: How to call and execute C code in Python? (Stefan Behnel)
   8. Re: How to call and execute C code in Python? (Stefan Behnel)
   9. Re: How to call and execute C code in Python? (Mark Lawrence)
  10. Re: How to call and execute C code in Python? (Stefan Behnel)
On 13 May 2012 13:29, Alec Taylor  wrote:
> There is an ordered dict type since Python 3.1[1] and Python 2.7.3[2].

I don't think that'll help the OP.  Python's OrderedDict keeps track
of the order in which the keys were inserted into the dictionary (a
bit like a list), it doesn't keep the keys sorted.

> If you are looking for the best possible self-sorting structure for
> searching, then perhaps you are looking for what's outlined in the
> 2002 article by Han & Thorup: Integer Sorting in O(n sqrt(log log n))
> Expected Time and Linear Space[3].

I can't access it but it seems to me it's not about self sorted data
structures, which is what the OP is looking for.

-- 
Arnaud

On 5/12/2012 5:17 AM Jean-Daniel said...
> Hello,
> 
> I have a long list of n date intervals that gets added or suppressed
> intervals regularly. I am looking for a fast way to find the intervals
> containing a given date, without having to check all intervals (less
> than O(n)).

ISTM the fastest way is to retrieve the list of intervals from a dict using the 
date as a key.  You don't say how long your list of intervals is, nor how large 
each interval can be so I don't have enough info to determine the setup reqs, 
but I'd suspect that a list of tens of thousands of intervals covering ranges 
of days to weeks would be doable.  If instead you're talking about millions of 
ranges covering years to decades I'd start elsewhere.

Emile



On Sun, May 13, 2012 at 11:25 PM, David Shi  wrote:
> Can anyone tell me how to call and exectute C code in Python?

Browse the documentation about Extending and Embedding Python, there's
an extensive API.

Chris Angelico

David Shi, 13.05.2012 15:25:
> Can anyone tell me how to call and exectute C code in Python?

Take a look at Cython, a Python-like language that supports native calls to
and from C/C++ code. It translates your code into very efficient C code, so
the wrapping code tends to be very fast (often faster than hand written C
code).

http://cython.org/

Here are a couple of examples:

http://docs.cython.org/src/tutorial/external.html

There's also the "ctypes" package in the standard library, which is usable
for simple wrapping cases that are not performance critical.

Stefan


On 13/05/2012 16:39, Chris Angelico wrote:
> On Sun, May 13, 2012 at 11:25 PM, David Shi  wrote:
>> Can anyone tell me how to call and exectute C code in Python?
>
> Browse the documentation about Extending and Embedding Python, there's
> an extensive API.
>
> Chris Angelico

I like your response, my first thought was to say "yes" :)

-- 
Cheers.

Mark Lawrence.


On 13/05/2012 16:58, Stefan Behnel wrote:
> David Shi, 13.05.2012 15:25:
>> Can anyone tell me how to call and exectute C code in Python?
>
> Take a look at Cython, a Python-like language that supports native calls to
> and from C/C++ code. It translates your cod

How to call and execute C code in Python?

2012-05-13 Thread David Shi
Can anyone tell me how to call and exectute C code in Python?

Regards.

David




 From: "python-list-requ...@python.org" 
To: python-list@python.org 
Sent: Friday, 11 May 2012, 5:35
Subject: Python-list Digest, Vol 104, Issue 57
 
- Forwarded Message -

Send Python-list mailing list submissions to
    python-list@python.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
    python-list-requ...@python.org

You can reach the person managing the list at
    python-list-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."

Today's Topics:

   1. Looking for video/slides from PyCon 2011... (Monte Milanuk)
   2. Re: Dealing with the __str__ method in classes with lots of
      attributes (Cameron Simpson)
   3. RE: Open Source: you're doing it wrong - the Pyjamas hijack
      (Adrian Hunt)
   4. RE: Creating a Windows installer for Python + a set of
      dependencies (Adrian Hunt)
   5. Re: Open Source: you're doing it wrong - the Pyjamas hijack
      (Chris Angelico)
   6. Re: Retrieving result from embedded execution (Chris Angelico)
   7. Finding the line number of an 'else' statement via ast
      (Michael Rene Armida)
...specifically the two lectures on creating GUI applications with Python + QT

http://us.pycon.org/2011/schedule/presentations/207/

Various searches on the 'Net don't seem to be turning up much... kinda curious 
as to why?

Anyone here know?

TIA,

Monte


On 10May2012 15:33, Andreas Tawn  wrote:
| Say I've got a class...
| 
| class test(object):
|     def __init__(self):
|         self.foo = 1
|         self.bar = 2
|         self.baz = 3
| 
| I can say...
| 
| def __str__(self):
|    return "foo: {0}\nbar: {1}\nbaz: {2}".format(self.foo, self.bar, self.baz)
| 
| and everything's simple and clean and I can vary the formatting if I need to.
| 
| This gets ugly when the class has a lot of attributes because the string 
construction gets very long.

This issue bit me once too often a few months ago, and now I have a
class called "O" from which I often subclass instead of from "object".
Its main purpose is a friendly __str__ method, though it also has a
friendly __init__.

Code:

    class O(object):
      ''' A bare object subclass to allow storing arbitrary attributes.
          It also has a nicer default str() action, and an aggressive repr().
      '''

      def __init__(self, **kw):
        ''' Initialise this O.
            Fill in attributes from any keyword arguments if supplied.
            This call can be omitted in subclasses if desired.
        '''
        for k in kw:
          setattr(self, k, kw[k])

      def __str__(self):
        return ( "<%s %s>"
                 % ( self.__class__.__name__,
                     ",".join([ "%s=%s" % (attr, getattr(self, attr))
                                for attr in sorted(dir(self)) if 
attr[0].isalpha()
                              ])
                   )
               )

So I have some code thus:

  from cs.misc import O
  ..
  class FilterModes(O):
    def __init__(self, **kw):
        # special case one parameter
        self._maildb_path = kw.pop('maildb_path')
        self._maildb_lock = allocate_lock()
        O.__init__(self, **kw)
  ..
  filter_modes = FilterModes(justone=justone,
                             delay=delay,
                             no_remove=no_remove,
                             no_save=no_save,
                             maildb_path=os.environ['MAILDB'],
                             maildir_cache={})


This removes a lot of guff from some common procedures.

Hope this helps,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

There's a fine line between pathos and pathetic.
        - David Stivers s...@stat.rice.edu DoD #857


 
lol, Cheers Chris.

Just so you know, I care about what and how I write... I almost always run my 
emails though a word-processor before sending. And, that has paid off for me: 
thanks to MS Word, MS Works and Open Office, I have better understanding of 
"correct" punctuation use (if not spelling and grammar) than most school 
leavers!!!

PS. It hasn't gone a miss that you are one of the core python-list responders 
(and I bet this goes for most of the python-list users): your responses, time 
and knowledge is appreciated... Thank you.


> Date: Fri, 11 May 2012 09:57:49 +1000
> Subject: Re: Open Source: you're doing it wrong - the Pyjamas hijack
> From: ros...@gmail.com
> To: python-list@python.org
> 
> On Fri, May 11, 2012 at 9:36 AM, Adrian Hunt  wrote:
> > All I did was to answer a mail sent to me by Ian Kelly (who I don't konw nor
> > have ever had any prior contact with) about releasing code under a
> > license... And, what I said stands: once anyone releases code, they are
> > bound by the license the

Looking for proven Python code for Line Simplication such as Douglas-Peucker

2012-05-08 Thread David Shi
Dear All,

I am looking for  proven Python code for Line Simplication such as 
Douglas-Peucker.

Regards.

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 102, Issue 64

2012-03-13 Thread David Shi
I am looking very simple and straightforward open source Python REST and SOAP 
demo modules.

I really need things which are very simple and convincing.   I want to 
demonstrate these to other people.

I want to promote you guys' interest.   I find asp and others frustrating and 
occupy too much in the market and popularity.

Can we do a new tidal wave to win a reasonable portion of the development 
market?

Send me materials to davidg...@yahoo.co.uk

I will give it a go on behalf of the Python community.

Regards.

David



 From: "python-list-requ...@python.org" 
To: python-list@python.org 
Sent: Tuesday, 13 March 2012, 20:35
Subject: Python-list Digest, Vol 102, Issue 64
 
- Forwarded Message -

Send Python-list mailing list submissions to
    python-list@python.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
    python-list-requ...@python.org

You can reach the person managing the list at
    python-list-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."

Today's Topics:

   1. Re: concatenate function (James Elford)
   2. Re: New Science Discovery: Perl Idiots Remain Idiots After A
      Decade!New    Science Discovery: Perl Idiots Remain Idiots After A
      Decade! (Kiuhnm)
   3. Re: Installing Python Apps on  Mac Lion
      (dilvanezanard...@gmail.com)
   4. Re: Software Engineer - (Pedro H. G. Souto)
   5. Re: Software Engineer - (Neil Cerutti)
   6. RE: Windows Contextmenu (Prasad, Ramit)
   7. Re: concatenate function (ferreirafm)
   8. Re: Installing Python Apps on Mac Lion (Benjamin Kaplan)
   9. Re: Windows Contextmenu (Terry Reedy)
  10. Re: concatenate function (Robert Kern)
On 13/03/12 16:02, ferreirafm wrote:
> Hi James, thank you for your replay. Indeed, the problem is qsub. And as
> warned by Robert, I don't have functions properly, but just scripts.
>  
> 
> --
> View this message in context: 
> http://python.6.n6.nabble.com/concatenate-function-tp4574176p4574511.html
> Sent from the Python - python-list mailing list archive at Nabble.com.

It looks like you're not calling wait() on your subprocesses: you're
effectively launching a bunch of processes, then not waiting for them to
finish before you ask the next process to operate on the same file.

If you haven't given it a good look-over already, the subprocess
documentation [1] is worth taking a little time over.

    [1]: http://docs.python.org/library/subprocess.html#popen-objects

James

On 3/12/2012 20:00, Albert van der Horst wrote:
[...]

Sorry for triple posting. I hadn't noticed the follow up and I was blaming my 
newsserver.
BTW, Python is the next language (right after Perl) I'm going to learn.
Then I'll probably have a look at Ruby...

Kiuhnm

Sábado, 25 de Junho de 2011 02h20min49s UTC+1, JKPeck escreveu:
> The Lion version of the OS on the Mac comes with Python 2.7 installed, but it 
> is in /System/Library/Frameworks/..., and this area is not writable by third 
> party apps.
> 
> So is there a consensus on what apps that typically install under the Python 
> site-packages directory should do in this situation?  Installing Python from 
> python.org puts it in the writable area /Library/Frameworks/Python.framework.
> 
> So, what should a Python app installer do?
> 
> Thanks

Hello,

currently I have:

/Library/Python/2.7/
/Library/Frameworks/Python.framework/Versions/2.7/
/Users/user/Library/Python/2.7/

With 3 folders "site-packages" and do not know why.
What's the difference?

Thanks.


On 2012-03-13 12:44 PM, Paul Rudin wrote:
> Just out of interest why do people object to job adverts here? Seems
> harmless enough...
Wannabe list admins... Or list admins with a need to proof themselves... Or 
none of the above.

On 2012-03-13, Pedro H. G. Souto  wrote:
> On 2012-03-13 12:44 PM, Paul Rudin wrote:
>> Just out of interest why do people object to job adverts here?
>> Seems harmless enough...
>
> Wannabe list admins... Or list admins with a need to proof
> themselves... Or none of the above.

A job listing here or there would fine. If the discussion were
clogged with them, it would be really annoying.

In addition, it's more efficient to post job listing in a place
where people looking for jobs can easily find them, and it's
annoying and useless to post them in a place where reader not
looking for jobs have to delete them.

-- 
Neil Cerutti

> > Now the script runs fine but I don't get all arguments from sys.argv.
> >
> > No mather how many files I mark in the explorer I only get one as an
> > argument.
> 
> You're missing out vital information:
> 
> * How have you attached this code to the context menu? What was
> the exact registry entry (or other method) you used?

From a quick Google search, it seems that most of the context menu
entries open a single file. If multiple file

Looking for a simple, generic Python module to provide a secure web service

2012-02-29 Thread David Shi
We are looking for a very simple, generic Python module to
provide a secure web service.   Ideally,
it can be put onto the computer and make it available via IIS.
 
Off we go.
 
Your help will be gratefully received.
 
Regards.
 
David-- 
http://mail.python.org/mailman/listinfo/python-list


Dynamically updating sections of webpage

2009-02-08 Thread David Shi
I want to dynamically update sections of webpage, something like a div or table 
or frame.
 
Where can I find best examples/demos for this?  Preferably with a generic 
loader.
 
I would also like to find a best book on this.  It needs to be concise, well 
explained and can be applied universally.
 
Is there a book or reference like "Accelerated DOM Scripting with Ajax, APIs 
and Libraries and Python"?
 
Can anyone point me towards the right direction.  Please -- no over loaded 
websites.
 
I like to read Newtonian style of text!
 
Sincerely,
 
David


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


Looking for an efficient Python script to download and save a .zip file programmatically

2009-01-10 Thread David Shi
I am looking for an efficient Python script to download and save a .zip file 
programmatically (from http or https call).
 
Regards.
 
David


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


Extracting data from XML containing CDATA and store data in a .dbf file

2008-12-18 Thread David Shi








I am looking for advice/efficient script to extract data from XML containing 
CDATA.
 
I wish to extract all the data and store it in a .dbf file.
 
Regards.
 
David



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


Python calling COM compliant .dll

2008-12-03 Thread David Shi
Hello, there.
 
I am looking for a concise working example of Python script calling COM 
compliant .dll.
 
Regards.
 
David


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


Has anyone tried calling zip.py in feedback.py and print out an innerHTML to provide a download link?

2008-11-11 Thread David Shi
Hello, there.
 
Has anyone tried calling zip.py in feedback.py and print out an innerHTML to 
provide a download link?
 
I find difficult to make it work.
 
Sincerely,
 
David
 #**
# Description:
#Zips the contents of a folder.
# Parameters:
#   0 - Input folder.
#   1 - Output zip file. It is assumed that the user added the .zip 
#   extension.  
#**

# Import modules and create the geoprocessor
#
import sys, zipfile, arcgisscripting, os, traceback
gp = arcgisscripting.create()

# Function for zipping files.  If keep is true, the folder, along with 
#  all its contents, will be written to the zip file.  If false, only 
#  the contents of the input folder will be written to the zip file - 
#  the input folder name will not appear in the zip file.
#
def zipws(path, zip, keep):
path = os.path.normpath(path)
# os.walk visits every subdirectory, returning a 3-tuple
#  of directory name, subdirectories in it, and filenames
#  in it.
#
for (dirpath, dirnames, filenames) in os.walk(path):
# Iterate over every filename
#
for file in filenames:
# Ignore .lock files
#
if not file.endswith('.lock'):
gp.AddMessage("Adding %s..." % os.path.join(path, dirpath, 
file))
try:
if keep:
zip.write(os.path.join(dirpath, file),
os.path.join(os.path.basename(path), 
os.path.join(dirpath, file)[len(path)+len(os.sep):]))
else:
zip.write(os.path.join(dirpath, file),
os.path.join(dirpath[len(path):], file)) 

except Exception, e:
gp.AddWarning("Error adding %s: %s" % (file, e))

return None

if __name__ == '__main__':
try:
# Get the tool parameter values
#
infolder = gp.GetParameterAsText(0)
outfile = gp.GetParameterAsText(1)  

# Create the zip file for writing compressed data. In some rare
#  instances, the ZIP_DEFLATED constant may be unavailable and
#  the ZIP_STORED constant is used instead.  When ZIP_STORED is
#  used, the zip file does not contain compressed data, resulting
#  in large zip files. 
#
try:
zip = zipfile.ZipFile(outfile, 'w', zipfile.ZIP_DEFLATED)
zipws(infolder, zip, True)
zip.close()
except RuntimeError:
# Delete zip file if exists
#
if os.path.exists(outfile):
os.unlink(outfile)
zip = zipfile.ZipFile(outfile, 'w', zipfile.ZIP_STORED)
zipws(infolder, zip, True)
zip.close()
gp.AddWarning("Unable to compress zip file contents.")

gp.AddMessage("Zip file created successfully")

except:
# Return any python specific errors as well as any errors from the 
geoprocessor
#
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n 
   " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"
gp.AddError(pymsg)

msgs = "GP ERRORS:\n" + gp.GetMessages(2) + "\n"
gp.AddError(msgs)



 


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


Calling Python from Python and .pyc problem

2008-11-07 Thread David Shi
Hello, there.I am using Python 2.5.  I used py_compile and made a .pyc file.  
However, it runs but never stops.  What is the best way tocompile a .py file.I 
am trying to customise the attached script to do the following:calling an 
external Python script and passing parameters into it.And run the external 
Python script in this attached script.Your advice will be deeply 
appreciated.Regards.David


  #!/usr/bin/python
import cgi, os, sys, string

def gush(data):
print "Content-type: text/html\n"
print "Thanks, %(name)s!" % vars(data)
print "Our customer's comments are always appreciated."
print "They drive our business directions, as well as"
print "help us with our karma."
print "Thanks again for the feedback!"
print "And feel free to enter more comments if you wish."
print ""+10*" "+"--Joe."

def whimper(data):
print "Content-type: text/html\n"
print "Sorry, %(name)s!" % vars(data)
print "We're very sorry to read that you had a complaint"
print "regarding our product__We'll read your comments"
print "carefully and will be in touch with you."
print "Nevertheless, thanks for the feedback."
print ""+10*" "+"--Joe."

def bail():
print "Content-type: text/html\n"
print "Error filling out form"
print "Please fill in all the fields in the form."
print 'http://localhost/comment.html";>'
print 'Go back to the form'
sys.exit()

class FormData:
""" A repository for information gleaned from a CGI form """
def __init__(self, form):
for fieldname in self.fieldnames:
if not form.has_key(fieldname) or form[fieldname].value == "":
bail()
else:
setattr(self, fieldname, form[fieldname].value)

class FeedbackData(FormData):
""" A FormData generated by the comment.html form. """
fieldnames = ('name', 'address', 'email', 'type', 'text')
def __repr__(self):
return "%(type)s from %(name)s on %(time)s" % vars(self)

DIRECTORY = '/home/brooks/public_html/cgi-bin/feedbackDir'

if __name__ == '__main__':
sys.stderr = sys.stdout 
form = cgi.FieldStorage()
data = FeedbackData(form)
if data.type == 'comment':
gush(data)
else:
whimper(data)
--
http://mail.python.org/mailman/listinfo/python-list


.pyc keeps running and never stops

2008-11-06 Thread David Shi
Dear All,
 
I am using Python 2.5 and used py_compile to produce a .pyc file.  The script 
runs well.  However, the .pyc keeps running and never stops.
 
Advices will be deeply appreciated.
 
Regards.
 
David



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


Looking for a nitty-gritty Python Ajax middleware script to fire off a number of processors

2008-11-06 Thread David Shi
Dear All,
 
I am looking for a nitty-gritty Python Ajax script to fire off a number of 
processing programmes, periodically checking their operations, sending messages 
back to an HTML div form by sending back the links of generated data files, to 
be downloaded by end users.
 
I am using .NET IIS 6.0 and Windows Server.
 
Regards.
 
David


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