Re: Dictionary from a list
On Aug 20, 2:10 pm, Peter Otten <[email protected]> wrote: > Jan Kaliszewski wrote: > > 20-08-2009 o 02:05:57 Jan Kaliszewski wrote: > > >> Or probably better: > > >> from itertools import islice, izip > >> dict(izip(islice(li, 0, None, 2), islice(li, 1, None, 2))) > > > Or similarly, perhaps more readable: > > > iterator = iter(li) > > dict((iterator.next(), iterator.next()) for i in xrange(len(li)/2)) > > I just can't stop posting this one: > > >>> from itertools import izip > >>> it = iter([1,2,3,4,5,6]) > >>> dict(izip(it, it)) > > {1: 2, 3: 4, 5: 6} > > I really tried, but yours drove me over the edge. > > Peter dict(zip(*[iter(l)]*2)) -- http://mail.python.org/mailman/listinfo/python-list
PY3.5 and nnumpy and scipy installation problem
Hi All— I am a beginner in Python and new to this list, but I am an experienced programming in a few other languages. Last year I installed numpy and scipy for Python3.3 on my computer with windows 7, 64 bit OS. Today I downloaded Python3.5, but I the installation for numpy 1.9.2 or 1.9.3 nor scipy 0.16.0 did work on the same computer. Basically the setup for both numpy and scipy did not work. Any ideas are greatly appreciated. Thanks in advance, Sincerely, EKE -- https://mail.python.org/mailman/listinfo/python-list
PY3.5 and nnumpy and scipy installation problem
Hi Steven, Thank you for the prompt response. What I meant by not working is the following: once I had py3.5 working, I downloaded numpy and scipy and unzipped them. After that I tried to install them. But there is no install file for either. There was a setup file which I thought would do the same. However, when I double clicked it, it showed a python window for a sec and that’s all. When I went to IDEL and typed import numpy as np I got the following error message which suggests PY did not find numpy. >>> import numpy as np Traceback (most recent call last): File "", line 1, in import numpy as np ImportError: No module named 'numpy' >>> Thanks again, EK -- https://mail.python.org/mailman/listinfo/python-list
PY3.5 and nnumpy and scipy installation problem
Hi All again— Thanks to all who have provided excellent tips for installing Python, Numpy, Scipy, etc. Paul suggested the use Anaconda which proved to be the best and easiest way for me. If I may add I stumbled on an academic site that spells out in great details how to install Python, numpy, scipy and others which helped me greatly. For any installation issue here is the link http://www.southampton.ac.uk/~fangohr/blog/installation-of-python-spyder-numpy-sympy-scipy-pytest-matplotlib-via-anaconda.html Thanks again---EK -- https://mail.python.org/mailman/listinfo/python-list
Pandas' loading a CSV file problem
Hi All---
I am new to Pandas. I am trying to load a csv file into pandas using
import pandas as pd
f = pd.read_csv(OSATemp.csv')
Even though I was able to read and manipulate the file in Python343, in
Pandas the file could not be loaded. When I run the above statement, I get
a series of massages such as
Traceback (most recent call last):
File "C:\Users\EK Esawi\Anaconda3\Scripts\file1.py", line 3, in
f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp.csv')
File "C:\Users\EK
Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 474, in
parser_f
Any help/suggestion is greatly appreciated—EKE
Here is a sample of my csv file:
120891
120891
120873
120890
120890
120754
120891
120890
120890
O
Geyser
RT
Time
Interval
Duration
Preplay
Height
Prediction
42
Old Faithful
8:16
3:00
43
Old Faithful
9:55
1:39
4:15
9:41
130+
9:49
44
Old Faithful
11:33
1:38
3:59
11:20
130
11:28
45
Old Faithful
13:00
1:27
4:00
13:00
140
13:06
46
Old Faithful
14:42
1:42
3:44
14:29
150
14:33
47
Old Faithful
16:08
1:26
>4:00
16:02
140+
16:15
56
Castle
E
9:36
9:40ie
75
Old Faithful
7:23
>3:00
76
Old Faithful
9:05
1:42
4:13
8:52
150
8:05
77
Old Faithful
10:37
1:32
4:08
10:32
130
10:38
78
Old Faithful
12:02
1:25
3:00
11:59
130
12:10
79
Old Faithful
13:38
1:36
>3:30
13:27
13:00
80
Old Faithful
15:08
1:30
4:05
15:02
15:01
81
Old Faithful
16:42
1:34
3:54
16:32
150
16:41
--
https://mail.python.org/mailman/listinfo/python-list
Pandas' loading a CSV file problem
Here is the whole output. EKE
Traceback (most recent call last):
File "C:\Users\EK Esawi\Anaconda3\Scripts\MyFile.py", line 3, in
f = pd.read_csv('c:/Users/EK Esawi/My Documents/Temp/GOSATemp1.csv')
File "C:\Users\EK
Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 474, in
parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\EK
Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 260, in _read
return parser.read()
File "C:\Users\EK
Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 721, in read
ret = self._engine.read(nrows)
File "C:\Users\EK
Esawi\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1170, in read
data = self._reader.read(nrows)
File "pandas\parser.pyx", line 769, in pandas.parser.TextReader.read
(pandas\parser.c:7544)
File "pandas\parser.pyx", line 791, in
pandas.parser.TextReader._read_low_memory (pandas\parser.c:7784)
File "pandas\parser.pyx", line 866, in
pandas.parser.TextReader._read_rows (pandas\parser.c:8617)
File "pandas\parser.pyx", line 973, in
pandas.parser.TextReader._convert_column_data (pandas\parser.c:9928)
File "pandas\parser.pyx", line 1033, in
pandas.parser.TextReader._convert_tokens (pandas\parser.c:10714)
File "pandas\parser.pyx", line 1130, in
pandas.parser.TextReader._convert_with_dtype (pandas\parser.c:12118)
File "pandas\parser.pyx", line 1150, in
pandas.parser.TextReader._string_convert (pandas\parser.c:12332)
File "pandas\parser.pyx", line 1382, in pandas.parser._string_box_utf8
(pandas\parser.c:17655)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 8:
invalid start byte
--
https://mail.python.org/mailman/listinfo/python-list
Pandas' loading a CSV file problem
Thanks you all for the input. Michiel's suggestion worked. At first It gave me an error about "low_memory"; once i sat low_memory to false, it worked. I am new to pandas and i am working on a 20,000 record csv file with mixed data types and in many cases, one entry (cell) has a combination of string and numeric values which will eventually be separated. Thanks again-EK -- https://mail.python.org/mailman/listinfo/python-list
cvxopt install problem
Hi All— I needed to install cvxopt on a 64 bit W7. I found out that cvxopt is incompatible with a 64 bit. It only compatible with a 32 bit which can be installed on a 64 bit computer and it works. I stumbled on this on another discussion group posting. The suggestion was to install python 32 bit on a 64 bit computer, then download cvxopt and install it via conda. Here is the suggestion from the posting [If you are using Windows, an easy solution could be the Anaconda distribution (http://continuum.io/downloads). Select and install the 32 bit version. It will be easier to install the cvxopt package. Search it in the binstar repository ( https://binstar.org/search?q=cvxopt). Open a console terminal and install it (e. g. "conda install -chttps://conda.binstar.org/omnia cvxopt").?] I did everything except the last command to install cvxopt, that’s “conda install -chttps://conda.binstar.org/omnia cvxopt". Here is the command I used: conda install c:/Users/eesawi0001/Downloads/cvxopt-1.1.7-py34.tar I kept getting invalid syntax Any help is greatly appreciated. EKE -- https://mail.python.org/mailman/listinfo/python-list
Re: Truly platform-independent DB access in Python?
Bruno Desthuilliers wrote: > bobrik wrote: > > Hello, > > > > I am using the Python DB API for access to MySQL. But it is not > > platform-independent > > It is. You don't have to change your Python code according to the OS or > CPU. > What I mean is that wiht platform-independent access, I should be able to not care on which operating system is the web server accessing my scripts where I use MySQLdb which I have to install (and therfore platform-dependently) compile myself. The important point is that MySQLdb is installed as an extra module. So you have to compile it manually, but what if the OS with server accessing the site that is on shared area changes? -- http://mail.python.org/mailman/listinfo/python-list
Re: Truly platform-independent DB access in Python?
[EMAIL PROTECTED] wrote: > I don't think you mean "platform-independent". I suspect you mean > "batteries included". Prior to the release of Python 2.5, no modules to > access SQL databases were distributed with core Python. Starting with 2.5, > sqlite access will be available: > > >>> import sqlite3 > >>> sqlite3.__file__ > '/Users/skip/local/lib/python2.5/sqlite3/__init__.pyc' > > So, if what you were really asking was "what SQL databases can I access > without installing any software other than Python?", then the answer is "No > SQL databases were distributed with Python prior to 2.5. Starting with > Python 2.5, access to sqlite databases is available by default." Python 2.5 > is due out soon (according to PEP 356, on 12 September). Yes, you excactly got my point. The thing is that I can't rely on Python 2.5 to be installed soon. So the only solution for me at this moment is to use jython and from there use Java JDBC API (sorry :-) But it would be great if the Python DB API compliant-modules would become parts of core python quickly. Python DB API itself is a great thing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Truly platform-independent DB access in Python?
Bruno Desthuilliers wrote: > > but what if the OS with server accessing the site that is on > > shared area changes? > > And what if Python is not installed on it ?-) > > Seriously, do you think that hosting companies swap OS very often ? No, I don't. But I was trying to find the best solution. :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Truly platform-independent DB access in Python?
Dennis Lee Bieber wrote: > On 28 Aug 2006 00:01:06 -0700, "bobrik" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > for that platform. Do you know of any Python solution for MySQL access > > that is 100% platform-independent? > > > Subprocess module invoking the MySQL command line utilities? Of > course, parsing the results will be painful... > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ Hmm, that is very interesting; and parsing won't be IMHO such a problem if the columns will be tab-separated. Thanks for your tip! -- http://mail.python.org/mailman/listinfo/python-list
Re: Truly platform-independent DB access in Python?
[EMAIL PROTECTED] wrote: ... snip ... > So, if what you were really asking was "what SQL databases can I access > without installing any software other than Python?", then the answer is "No > SQL databases were distributed with Python prior to 2.5. Starting with > Python 2.5, access to sqlite databases is available by default." Python 2.5 > is due out soon (according to PEP 356, on 12 September). So I finally decided to go with sqlite, compile the module myself for the time being and hoping python will be upgraded to 2.5 at latest at the same time as any potential OS (or architecture) upgrade. -- http://mail.python.org/mailman/listinfo/python-list
Pandsa to Excel conversion issue
Hi All-- I am using Pandas to read an excel file which is very "dirty" and needs cleaning. I read the file via pandas and did not setup dtypes or converters hoping i can do so later.. When i run my code, most columns did come out as strings but i cannot convert them to float or integer using astype or pandas.to numeric method. Every time i tried, i get the same error listed below Here is my code import pandas as pd import numpy as np MyFile='C:/Users/Temp.xlsx' df=pd.read_excel(io=MyFile, nrows=100) The error message i get when i tried to convert a string like '22.3' via astype or pd.to_numeric is below Unable to parse string "22." at position 0 Thanks in advance EK -- https://mail.python.org/mailman/listinfo/python-list
