Re: [py-usr] flake8 gives me a W605 but Python don't

2022-09-10 Thread Reto
On Sat, Sep 10, 2022 at 06:46:33PM +, [email protected] wrote:
> 
> But running this with Python 3.9.2 makes no problem. Python doesn't
> give me a `SyntaxWarning` or anything else. Python doesn't give me an
> error or warning. Only `flymake8` gives me this error.

Well, it's not a syntax error.
Escape sequences with no meaning simply yield the escape sequence.

As in, '\d' is simply '\d', in contrast  with say '\u' which is invalid
and if fact throws a SyntaxError.


>Unlike Standard C, all unrecognized escape sequences are left in the string 
>unchanged, i.e., the backslash is left in the result. (This behavior is useful 
>when debugging: if an escape sequence is mistyped, the resulting output is 
>more easily recognized as broken.) It is also important to note that the 
>escape sequences only recognized in string literals fall into the category of 
>unrecognized escapes for bytes literals.

from 
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: score function in linear regression model

2022-10-24 Thread Reto
On Sun, Oct 23, 2022 at 05:11:10AM -0700, Fatemeh Heydari wrote:
> model.score(X,Y)

That will basically check how good your model is.

It takes a bunch of X values with known values, which you provide in Y
and compares the output of model.Predict(X) with the Y's and gives you
some metrics as to how good that performed.

In the case of linear regression that be R^2, the coefficient of determination
of the prediction.

Cheers,
Reto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: issue with seaborn

2021-02-20 Thread Reto
Don't have the original email, hence replying this way.

On Sat, Feb 20, 2021 at 12:13:30PM +0100, jak wrote:
> Il 20/02/2021 01:56, Dino ha scritto:
> >
> > trying to do some dayaviz with Italian Covid Open Data (
> > https://github.com/italia/covid19-opendata-vaccini/ )
> >
> > here's how I pull my data:
> > 
> > import sys
> > import urllib.request
> > import pandas as pd
> > import ssl
> > ssl._create_default_https_context = ssl._create_unverified_context
> >
> > URL = 
> > "https://github.com/italia/covid19-opendata-vaccini/blob/master/dati/somministrazioni-vaccini-latest.csv?raw=true";
> >
> >
> > with urllib.request.urlopen(URL) as url:
> >      df = pd.read_csv(url)
> > 
> >
> > One of my diagrams came out screwed up today, and I am having a hard
> > time understanding what went wrong:
> >
> > https://imgur.com/a/XTd4akn
> >
> > Any ideas?
> >
> > Thanks
>
>
> I don't think this is the cause of your problem and in addition I don't
> know about pandas. In any case you send pandas some records that contain
> the date in string format and this gives the alphabetic continuity but
> if the data contained time holes, these would not be represented in your
> graph. Maybe you should add an intermediate step and convert strings
> dates to datetime format before you create the chart (but perhaps pandas
> takes care of this. I don't know this).

Pretty much what he said...
Parse the dates. Oh and you generally don't need the dance with urllib, pandas
can do that for you.

```
data_url = 
r"https://github.com/italia/covid19-opendata-vaccini/blob/master/dati/somministrazioni-vaccini-latest.csv?raw=true";

df = pd.read_csv(data_url, parse_dates=True, index_col="data_somministrazione")

plt.figure(figsize=(15,10))
plt.xticks(rotation=70)
sns.lineplot(x=df.index, y="prima_dose", data=df, hue="nome_area", ci=None)
```

Yields: https://labrat.space/irc/3b0be1f11e6c687b/download%20(1).png

Cheers,
Reto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Saving/exporting plots from Jupyter-labs?

2022-02-14 Thread Reto
On Mon, Feb 14, 2022 at 08:54:01PM +, Martin Schöön wrote:
> 1) In notebooks I can save a plot by right-clicking on it and do
> save image as. In Jupyter-lab that does not work and so far I
> have not been able to figure out how to do it. Yes, I have looked
> in the documentation.

Shift + right click brings up the usual browser menu
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: venv and executing other python programs

2022-02-14 Thread Reto
On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote:
> How to people here deal with that?

Don't activate the venv for those programs then?
The point of a venv is that you only enter it when you actually want
that specific python stack.

Get yourself a terminal that can either multiplex, or add something like
tmux or screen to the mix if you frequently need other python tools
during development.
Or just install those in you venv, after all if you
do use them for dev they are part of your dependencies, so declare them
as such.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python string with character exchange

2019-07-14 Thread Reto
On Sun, Jul 14, 2019 at 12:20:56PM -0400, Matt Zand wrote:
> Given a string, return a new string where the first and last chars have
> been exchanged.

This sounds awfully like a homework question.
What did you try?
What concepts are you missing?

Did you already look into slicing / getting element from a list?
That will be what you need in the end.

You can easily get a character from a string like this

```
a = "some random string"
print(a[0])
```

strings are immutable in python, meaning you will need to create a new string.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Reto
On Sat, Apr 04, 2020 at 07:00:23PM -0400, Luca wrote:
> dframe.to_string
> 
> gives:
> 
>  0  a0  b0  c0  d0
> 1  a1  b1  c1  d1
> 2  a2  b2  c2  d2
> 3  a3  b3  c3  d3>

That's not the output of to_string.
to_string is a method, not an attribute which is apparent by the

> 

comment in your output.
You need to call it with parenthesis like `dframe.to_string()`

> Can I evaluate this string to obtain a new dataframe like the one that
> generated it?

As for re-importing, serialize the frame to something sensible first.
There are several options available, csv, json, html... Take your pick.

You can find all those in the dframe.to_$something namespace
(again, those are methods, make sure to call them).

Import it again with pandas.read_$something, choosing the same serialization 
format
you picked for the output in the first place.

Does this help?

Cheers,
Reto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: print small DataFrame to STDOUT and read it back into dataframe

2020-04-06 Thread Reto
On Mon, Apr 06, 2020 at 06:29:01PM -0400, Luca wrote:
> so, given a dataframe, how do I make it print itself out as CSV?

read the docs of to_csv...

> And given CSV data in my clipboard, how do I paste it into a Jupiter cell
> (possibly along with a line or two of code) that will create a dataframe out
> of it?

```python
import pandas as pd
import io
df = pd.DataFrame(data=range(10))
out = df.to_csv(None)
new = pd.read_csv(io.StringIO(out), index_col=0)
```

That'll do the trick... any other serialization format works similarly.
you can copy out to wherever, it's just csv data.

Cheers,
Reto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fake news Detect

2020-07-17 Thread Reto
What you want is called "natural language processing" and whole research papers
have been written about this topic.

Search your favorite research paper index for those keywords, say google 
scholar.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: don't quite understand mailing list

2018-09-06 Thread Reto Brunner
On Thu, Sep 06, 2018 at 07:10:10PM +, VanDyk, Richard T wrote:
> Can you please take me off the mailing list or prevent questions from coming 
> to me. Can you advise me on my problem or point me in the right direction?
> Thanks.
> https://mail.python.org/mailman/listinfo/python-list

What do you think the link, which is attached to every email you receive
from the list, is for? Listinfo sounds very promising, doesn't it?

And if you actually go to it you'll find:
"To unsubscribe from Python-list, get a password reminder, or change your 
subscription options enter your subscription email address"

So how about you try that?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating a hot vector (numpy)

2016-04-17 Thread Reto Brunner
Hi,
It is called broadcasting an array, have a look here:
http://docs.scipy.org/doc/numpy-1.10.1/user/basics.broadcasting.html

Greetings,
Reto

On Mon, Apr 18, 2016, 02:54 Paulo da Silva 
wrote:

> Hi all.
>
> I have seen this "trick" to create a hot vector.
>
> In [45]: x
> Out[45]: array([0, 1])
>
> In [46]: y
> Out[46]: array([1, 1, 1, 0, 0, 1, 0, 0], dtype=uint8)
>
> In [47]: y[:,None]
> Out[47]:
> array([[1],
>[1],
>[1],
>[0],
>[0],
>[1],
>[0],
>[0]], dtype=uint8)
>
> In [48]: x==y[:,None]
> Out[48]:
> array([[False,  True],
>[False,  True],
>[False,  True],
>[ True, False],
>[ True, False],
>[False,  True],
>[ True, False],
>[ True, False]], dtype=bool)
>
> In [49]: (x==y[:,None]).astype(np.float32)
> Out[49]:
> array([[ 0.,  1.],
>[ 0.,  1.],
>[ 0.,  1.],
>[ 1.,  0.],
>[ 1.,  0.],
>[ 0.,  1.],
>[ 1.,  0.],
>[ 1.,  0.]], dtype=float32)
>
> How does this (step 48) work?
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Call for Assistance

2016-08-09 Thread Reto Brunner
What on earth isn't "free" enough about

You are free to:
Share — copy and redistribute the material in any medium or format

Adapt — remix, transform, and build upon the material

The licensor cannot revoke these freedoms as long as you follow the license
terms.

It is even a viral (copy left) licence, so even a fsf member should be happy

On Tue, Aug 9, 2016, 16:59 Lutz Horn  wrote:

> Am 08/09/2016 um 03:52 AM schrieb Charles Ross:
> > The book is being hosted at https://github.com/chivalry/meta-python
>
> CC-BY-NC-SA is not a license for free (as in speech) content. Is that
> what you want?
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: creating multiple python Django projects in Windows environment

2016-03-19 Thread Reto Brunner
Hi Ivan,
The idea is basically that you provide a web frontend on a server (internet
or intranet) which provides just a web interface that enables eg the upload
of an excel sheet.

On the server the data gets processed (in this example  makes the "clean"
excel) and then allows the user to download the results.

The only dependency the user has is a web browser then and only the server
needs python,  django and the other stuff you need for the parsing.

On Sat, Mar 19, 2016, 01:07 Ivan Jankovic  wrote:

> Hi Reto.
>
> I understand that i need to run Django on a server.  I have deployed
> projects to AWS (ubuntu) in the past.
>
> My main question is around how to tie it into the windows environment.
>
> Ivan
> On Mar 18, 2016 7:40 PM, Reto Brunner  wrote:
>
> Well you can just put it on a proper server. In the end that's what django
> is for yes?
> In case that isn't an option and you don't want to install python there's
> docker,  but then you would need to install that...
>
> On Fri, Mar 18, 2016, 20:05 jogaserbia  wrote:
>
> Hello,
>
> At work, I have a windows environment.
>
> I have created applications on my linux ubuntu machine at home that I
> would like to use for work purposes.
>
> For example, I have:
>
> - a Django project that takes inputs from users and creates pdfs
> - a Django project that tracks various company related information
> - a python project that parses word documents and returns clean excel
> documents (the documents to be parsed would be on the local machine)
> - a python project that uses scikit learn to make decisions which
> customers should get which marketing campaigns
>
> What I would like to know is how I should create an environment (vagrant,
> virtualbox running linux on an existing Windows machine in my network?) and
> connect it to my windows environment so that staff can assess these
> applications.
>
> I would prefer not to have to install python on everyone's computer who
> might need to use the programs so as not to have to maintain each
> workstation.
>
> Can someone please give me ideas on what I should read about (or pay
> someone to do) that would enable me to create a basis on which multiple
> Python (web and non-web) applications can be access by staff in a windows
> environment.
>
> Thank you, and sorry if the question is a bit convoluted, I am trying to
> get my head around how to create a basis from which to create company wide
> access to applications.
>
> Ivan
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: creating multiple python Django projects in Windows environment

2016-03-19 Thread Reto Brunner
Well you can just put it on a proper server. In the end that's what django
is for yes?
In case that isn't an option and you don't want to install python there's
docker,  but then you would need to install that...

On Fri, Mar 18, 2016, 20:05 jogaserbia  wrote:

> Hello,
>
> At work, I have a windows environment.
>
> I have created applications on my linux ubuntu machine at home that I
> would like to use for work purposes.
>
> For example, I have:
>
> - a Django project that takes inputs from users and creates pdfs
> - a Django project that tracks various company related information
> - a python project that parses word documents and returns clean excel
> documents (the documents to be parsed would be on the local machine)
> - a python project that uses scikit learn to make decisions which
> customers should get which marketing campaigns
>
> What I would like to know is how I should create an environment (vagrant,
> virtualbox running linux on an existing Windows machine in my network?) and
> connect it to my windows environment so that staff can assess these
> applications.
>
> I would prefer not to have to install python on everyone's computer who
> might need to use the programs so as not to have to maintain each
> workstation.
>
> Can someone please give me ideas on what I should read about (or pay
> someone to do) that would enable me to create a basis on which multiple
> Python (web and non-web) applications can be access by staff in a windows
> environment.
>
> Thank you, and sorry if the question is a bit convoluted, I am trying to
> get my head around how to create a basis from which to create company wide
> access to applications.
>
> Ivan
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list