Re: Is there a way to subtract 3 from every digit of a number?
On 2021-02-20 at 20:49:15 -0800, Dan Stromberg wrote: > On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > > > I just wrote a very short code can fulfill your needs: > > > > a = 2342 > > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > > > I tend to favor plenty of temporary variables with descriptive names, but > this is indeed short. > > Apart from that, you may find that using a generator expression is shorter > and clearer than map+lambda. It should allow to additionally eliminate the > list conversion. > > So in the terse form you've got there, it'd be more like: > b = int(''.join(str((int(x) - 3) % 10) for x in str(a)) > > But in real life, I'd try to use descriptive variable names for some of the > subexpressions in that. This makes reading and debugging simpler, which is > important because the maintenance phase of software is almost always much > longer and costly than the development phase. And although you could do a > generator expression for each of the different parts of (int(x) - 3) % 10, > I kinda like having a named function for just that piece. > > So maybe: > def rot_3(character): > """Convert to int, subtract 3 and mod 10.""" > digit = int(character) > assert 0 <= digit <= 9 > return (digit - 3) % 10 > > > def descriptive_minus_three_caesar(input_number): > """Convert to a -3 caesar cypher on an integer.""" > string_number = str(input_number) > rotated_digits = (rot_3(character) for character in string_number) > output_string = ''.join(str(digit) for digit in rotated_digits) > output_number = int(output_string) > return output_number >>> descriptive_minus_three_caesar('38') 5 The problem is underspecified, and the examples are lacking, but based on the phrase "each digit" and the examples that contain a 3, I'd prefer to see "38" become "05." -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On Sun, Feb 21, 2021 at 3:50 PM Dan Stromberg wrote: > > On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > > > I just wrote a very short code can fulfill your needs: > > > > a = 2342 > > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > > > I tend to favor plenty of temporary variables with descriptive names, but > this is indeed short. > > Apart from that, you may find that using a generator expression is shorter > and clearer than map+lambda. It should allow to additionally eliminate the > list conversion. For what it's worth, map doesn't require list conversion either - it's perfectly happy (as are most things in Python) to iterate over a string. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > I just wrote a very short code can fulfill your needs: > > a = 2342 > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > I tend to favor plenty of temporary variables with descriptive names, but this is indeed short. Apart from that, you may find that using a generator expression is shorter and clearer than map+lambda. It should allow to additionally eliminate the list conversion. So in the terse form you've got there, it'd be more like: b = int(''.join(str((int(x) - 3) % 10) for x in str(a)) But in real life, I'd try to use descriptive variable names for some of the subexpressions in that. This makes reading and debugging simpler, which is important because the maintenance phase of software is almost always much longer and costly than the development phase. And although you could do a generator expression for each of the different parts of (int(x) - 3) % 10, I kinda like having a named function for just that piece. So maybe: def rot_3(character): """Convert to int, subtract 3 and mod 10.""" digit = int(character) assert 0 <= digit <= 9 return (digit - 3) % 10 def descriptive_minus_three_caesar(input_number): """Convert to a -3 caesar cypher on an integer.""" string_number = str(input_number) rotated_digits = (rot_3(character) for character in string_number) output_string = ''.join(str(digit) for digit in rotated_digits) output_number = int(output_string) return output_number -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On Sat, Feb 20, 2021 at 09:40:48AM -0500, C W wrote: > Hello everyone, > > I'm curious if there is a way take number and back each digit by 3 ? > > 2342 becomes 9019 > 8475 becomes 5142 > 5873 becomes 2540 > > The tricky part is that 2 becomes 9, not -1. > [...] I just wrote a very short code can fulfill your needs: a = 2342 b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) It does the following things: 1. Convert a number into a string, and then convert this string into a list of single characters. 2. Write a lamdba expression to apply your conversion rules to a single-character type number (just subtract 3 and then modulo 10). 3. Apply the lambda expression to the above string list through map. 4. Finally join the modified list into a string and convert it into an integer. -- OpenPGP fingerprint: 3C47 5977 4819 267E DD64 C7E4 6332 5675 A739 C74E signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On 21/02/2021 06.02, jak wrote: > Il 20/02/2021 15:40, C W ha scritto: >> Hello everyone, >> >> I'm curious if there is a way take number and back each digit by 3 ? >> >> 2342 becomes 9019 >> 8475 becomes 5142 >> 5873 becomes 2540 >> >> The tricky part is that 2 becomes 9, not -1. >> >> Here's my toy example and what I attempted, >>> test_series = pd.Series(list(['2342', '8475', '5873'])) >>> test_series >> 0 2342 >> 1 8475 >> 2 5873 >> dtype: object >> >>> test_series.str.split('') >> [, 2, 3, 4, 2, ] >> [, 8, 4, 7, 5, ] >> [, 5, 8, 7, 3, ] >> dtype: object >> >> What a good approach to this? Is there a method or function that >> should be >> handling this? >> >> Thanks so much! >> >> Mike >> > num='0123456789' n=8475 sn = '' for x in str(n): > sn += num[(int(x) - 3) % 10] > > int(sn) > 5142 This code doesn't *look* correct (in the original post, via email reflector) because the loop is not indented Per previous respondents identifying it as likely to be an 'homework assignment', does it help the student if you/me/we "give" the answer? How has the student proven that (s)he has learned the material? (apologies for criticism: I readily assume your motivation was to be helpful) The problem is a Caesar Cipher - disguised, because most examples/usage of such is for alphanumeric messages. This topic is often used for ComSc examples to demonstrate modulo arithmetic and/or circular data structures, eg a bounded-queue (per other's responses). -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
RE: Is there a way to subtract 3 from every digit of a number?
Wouldn't it be nice, Grant, if Homework was assigned with statements like: "Using only the features of the language covered up to chapter 3, meaning individual variables and lists of them and simple loops and only using the arithmetic built-in variable of +, -, % ... Solve this problem " But there is an actual silly model and application to this homework assignment. Consider the kind of lock shown in the video (or skip the video) that has three or more wheels of sorts containing digits 0-9 and you rotate each wheel to a setting read down or across like 359. https://www.youtube.com/watch?v=BMeqkUiui20&feature=emb_logo If you are lazy, you can put the lock on your locker and move each wheel the same number of units in one direction. It is now securely locked and might show 682 or 026 and if nobody touches it and perturbs the setting, you can come back and perturb it back three units the other way (or continue seven more) and open it. See? A Very practical (albeit impractical) example of how this might be fractionally useful! I wrote a solution to the problem the student asked for that I chose not to share here that is one line of code including an embedded list comprehension to do the loop. If a student of mine in a beginning class offered me that solution, I would be fairly certain it was NOT their work, though, nor what I wanted them to do. Now the translate method, albeit elegant, is again not likely to be the one wanted as they probably have no idea that functionality exists. Heck, in some languages, they may not yet know looping constructs exist and be asked to use something like a GOTO! LOL! And, somewhere out there is something that implements the commonly (at least in the past) rot13 semi-cryptography of rotating the alphabet for fun and profit. You probably can load such a module and find a function that can rotate a numeric string by 3 or -3 and use that for a trivial solution. None of the above should be considered as having done the darn assignment as requested. However, if a student gave me a decent solution and ADDED that some search and research suggested other advanced methods they might use on the job later, sure, maybe they get extra credit. -Original Message- From: Python-list On Behalf Of Grant Edwards Sent: Saturday, February 20, 2021 12:31 PM To: python-list@python.org Subject: Re: Is there a way to subtract 3 from every digit of a number? On 2021-02-20, MRAB wrote: > Have a look at the 'translate' method of the 'str' class. That's very clever, but being too clever on homework assignemnts doesn't always get a good grade. If they've just studied iteration, the modulus operator, and int/str conversions, then I'd avise using the "dumb" method. -- Grant -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: use set notation for repr of dict_keys?
On 20/02/2021 20.25, Wolfgang Stöcher wrote: > Having a dict like > d = {'one': 1, 'two': 2} > the representation of its keys > repr(d.keys()) > gives > "dict_keys(['one', 'two'])" > > But since the keys are unique, wouldn't a representation using the set > notation > be more intuitive, i.e. what about changing the output of > dict_keys.__repr__ to > "dict_keys({'one', 'two'})" > (using curly braces instead of brackets) When considering the data-returned, the logic of formatting as a set makes sense. So, why did the Python-gods decide otherwise? Let's start by asking what it actually is: >>> d = {'one': 1, 'two': 2} >>> repr(d.keys()) "dict_keys(['one', 'two'])" >>> k = d.keys() >>> type( k ) So, the output is not a set (as you say) but nor (as apparently-indicated by the square-brackets) is it actually a list! Not much help there, then. So, let's use help() to see if that helps, hah! (long listing, so not reproduced here). No joy there either. Is it actually one of our 'standard' collections at all? >>> k is dict False >>> k is list False >>> k is set False >>> k is tuple False OK, that makes reasonable sense. Perhaps dict_keys are a sub-class then? >>> isinstance( k, dict ) False >>> isinstance( k, list ) False >>> isinstance( k, set ) False >>> isinstance( k, tuple ) False Still going 'nowhere' fast! It is (apparently) reported as a list, and we'd like to think of it as a set. So, compare help() output with the attributes of list and set (and/or other collections). There are considerable differences (again, not reproduced here due to length). However, still not revealing any answers! If we de-construct the data contained in a dictionary, then as well as the keys, we should consider the values: >>> d {'one': 1, 'two': 2} >>> k = d.keys() >>> k dict_keys(['one', 'two']) >>> v = d.values() >>> v dict_values([1, 2]) Hah, they are (apparently) considered a list as well, but have another distinct type/are another custom-object. Still not making progress though! We've looked at the data/the output and found nothing much! Now, let's totally invert our view of the matter: Instead of deconstructing the original dictionary, consider the purpose of repr()? <<>> #repr Thus, we should be able to take the output of repr() and re-create the original object. Because a dictionary consists of key-value pairs, we will need both 'sets' of components: >>> new_d = dict( zip( k, v ) ) >>> new_d {'one': 1, 'two': 2} Ahah! Now, we realise that whereas a list-like #list data structure maintains the sequence of its elements, a set #set is not required to do so. Thus, if "k" were a set, what is produced on your machine may be different to what happens on mine/no guarantees: Possibly @Wolfgang's machine = >>> k { 'one', 'two' } Possibly @dn's machine = >>> k { 'two', 'one' } Thus no guarantee that when we try to re-combine keys and values they would correspond correctly! - and if we applied the same to data - even worse: combinatorial issue! Web.Refs: #repr: https://docs.python.org/3/reference/datamodel.html#basic-customization #list: and #set: https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On 2/20/2021 12:02 PM, jak wrote: Il 20/02/2021 15:40, C W ha scritto: Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, test_series = pd.Series(list(['2342', '8475', '5873'])) test_series 0 2342 1 8475 2 5873 dtype: object test_series.str.split('') [, 2, 3, 4, 2, ] [, 8, 4, 7, 5, ] [, 5, 8, 7, 3, ] dtype: object What a good approach to this? Is there a method or function that should be handling this? MRAB gave the proper answer -- str.translate (and str.maketrans. >>> num='0123456789' >>> n=8475 >>> sn = '' >>> for x in str(n): sn += num[(int(x) - 3) % 10] > >>> int(sn) > 5142 This works, but suggesting to beginners that they build strings with += is an O(n*n) trap. Try it with a string of millions of digits. Much better to use str.join ''.join(num[(int(c)-3) % 10] for c in '9876543210') #'6543210987' Even better, improve your string lookup idea to avoid the arithmetic. lookup1 = '7890123456' ''.join(lookup1[int(c)] for c in '9876543210') #'6543210987' To avoid the int call, make a lookup dictionary lookup2 = {a:b for a, b in zip('0123456789', '7890123456')} ''.join(lookup2[c] for c in '9876543210') #'6543210987' To run faster, use the str methods maketrans and translate to do the same thing. lookup3 = str.maketrans('0123456789', '7890123456') '9876543210'.translate(lookup3) #'6543210987' Note that "built-in function" str.maketrans is in effect a static method of the str class and is not an instance method. '0123456789'.maketrans('7890123456') does not work. The reason is that the first argument can be a dict instead of a string. Indeed, the dict could be the char-char mapping above created with the dict comprehension. Also, the resulting dict maps unicode ordinals to unicode ordinals, rather than chars to chars, because at the C level, a string *is* a sequence of unsigned ints with a PyObject wrapper. >>> lookup3 {48: 55, 49: 56, 50: 57, 51: 48, 52: 49, 53: 50, 54: 51, 55: 52, 56: 53, 57: 54} In Python, this is {ord(a):ord(b) for a, b in zip('0123456789', '7890123456')} -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On 2021-02-20, Dan Stromberg wrote: > Convert to a str. > Convert to a list of ints, one for each digit > Add 7 mod 10, for each digit in the list I'd probably subtract 3 (mod 10), so as to more obviously match the stated requirement. > Convert to a list of single-character str's > Catenate those str's back together > Convert to a single int -- https://mail.python.org/mailman/listinfo/python-list
Re: use set notation for repr of dict_keys?
On 2/20/2021 2:25 AM, Wolfgang Stöcher wrote: Having a dict like d = {'one': 1, 'two': 2} the representation of its keys repr(d.keys()) gives "dict_keys(['one', 'two'])" But since the keys are unique, wouldn't a representation using the set notation be more intuitive, i.e. what about changing the output of dict_keys.__repr__ to "dict_keys({'one', 'two'})" (using curly braces instead of brackets) From 3.0 to 3.7?, when dict keys were unordered, that might have made sense. But now that dict keys are insertion ordered, I think the list brackets suggesting a significant key order is better. There is also the issue that representation changes can break code and therefore need substantial reason. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On 2021-02-20, MRAB wrote: > Have a look at the 'translate' method of the 'str' class. That's very clever, but being too clever on homework assignemnts doesn't always get a good grade. If they've just studied iteration, the modulus operator, and int/str conversions, then I'd avise using the "dumb" method. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
Convert to a str. Convert to a list of ints, one for each digit Add 7 mod 10, for each digit in the list Convert to a list of single-character str's Catenate those str's back together Convert to a single int On Sat, Feb 20, 2021 at 6:45 AM C W wrote: > Hello everyone, > > I'm curious if there is a way take number and back each digit by 3 ? > > 2342 becomes 9019 > 8475 becomes 5142 > 5873 becomes 2540 > > The tricky part is that 2 becomes 9, not -1. > > Here's my toy example and what I attempted, > > test_series = pd.Series(list(['2342', '8475', '5873'])) > > test_series > 02342 > 18475 > 25873 > dtype: object > > > test_series.str.split('') > [, 2, 3, 4, 2, ] > [, 8, 4, 7, 5, ] > [, 5, 8, 7, 3, ] > dtype: object > > What a good approach to this? Is there a method or function that should be > handling this? > > Thanks so much! > > Mike > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
Il 20/02/2021 15:40, C W ha scritto: Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, test_series = pd.Series(list(['2342', '8475', '5873'])) test_series 02342 18475 25873 dtype: object test_series.str.split('') [, 2, 3, 4, 2, ] [, 8, 4, 7, 5, ] [, 5, 8, 7, 3, ] dtype: object What a good approach to this? Is there a method or function that should be handling this? Thanks so much! Mike >>> num='0123456789' >>> n=8475 >>> sn = '' >>> for x in str(n): sn += num[(int(x) - 3) % 10] >>> int(sn) 5142 >>> -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On 2021-02-20 14:40, C W wrote: Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, test_series = pd.Series(list(['2342', '8475', '5873'])) test_series 02342 18475 25873 dtype: object test_series.str.split('') [, 2, 3, 4, 2, ] [, 8, 4, 7, 5, ] [, 5, 8, 7, 3, ] dtype: object What a good approach to this? Is there a method or function that should be handling this? Have a look at the 'translate' method of the 'str' class. -- https://mail.python.org/mailman/listinfo/python-list
use set notation for repr of dict_keys?
Having a dict like d = {'one': 1, 'two': 2} the representation of its keys repr(d.keys()) gives "dict_keys(['one', 'two'])" But since the keys are unique, wouldn't a representation using the set notation be more intuitive, i.e. what about changing the output of dict_keys.__repr__ to "dict_keys({'one', 'two'})" (using curly braces instead of brackets) Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to subtract 3 from every digit of a number?
On 2021-02-20 at 09:40:48 -0500, C W wrote: > Hello everyone, > > I'm curious if there is a way take number and back each digit by 3 ? > > 2342 becomes 9019 > 8475 becomes 5142 > 5873 becomes 2540 > > The tricky part is that 2 becomes 9, not -1. > > Here's my toy example and what I attempted, > > test_series = pd.Series(list(['2342', '8475', '5873'])) > > test_series > 02342 > 18475 > 25873 > dtype: object > > > test_series.str.split('') > [, 2, 3, 4, 2, ] > [, 8, 4, 7, 5, ] > [, 5, 8, 7, 3, ] > dtype: object > > What a good approach to this? Is there a method or function that should be > handling this? I'm assuming that this is homework or some other academic exercise, so I'm being deliberately vague on some of the details. That said: Break it down. (1) Write a function that takes a number and returns the result of subtracting three from it. This function should also handle the "special" cases of 0, 1, and 2. Look up the modulo operator for a better way than actually special-casing them. (2) Python has several ways of building a list by transforming the elements of a list one at a time and building a new list from the results. Consider a simple iterative approach, but also look up the builtin "map" function and "list comprehensions." One interesting decision is where to convert the individual digits of the original numbers from strings to integers. There are arguments for doing it in either of the parts I've just outlined, as well as making it a sort of Part 1a and applying both Part 1 and Part 1a to each digit. > Thanks so much! HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list
Re: issue with seaborn
Dino wrote: > 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? > I first downloaded a local copy of the .csv file using wget URL Then the python code below following the plot parameters shown in your imgur.com image which was executed in a jupyter notebook # it_covid.py --- import pandas as pd import seabornas sns import numpy as np import matplotlib.pyplot as plt df = pd.read_csv( 'data/somministrazioni-vaccini-latest.csv' ) plt.figure( figsize = ( 20 , 10 ) ) plt.xticks( rotation = 70 ) sns.lineplot( x= "data_somministrazione" , y= "prima_dose" , data = df , hue = "nome_area" , ci = None ) plt.show() # --- The resulting plot doesn't seem to be cluttered as the one that you posted http://csphx.net/image/it_covid.png -- Stanley C. Kitching Human Being Phoenix, Arizona -- https://mail.python.org/mailman/listinfo/python-list
Is there a way to subtract 3 from every digit of a number?
Hello everyone, I'm curious if there is a way take number and back each digit by 3 ? 2342 becomes 9019 8475 becomes 5142 5873 becomes 2540 The tricky part is that 2 becomes 9, not -1. Here's my toy example and what I attempted, > test_series = pd.Series(list(['2342', '8475', '5873'])) > test_series 02342 18475 25873 dtype: object > test_series.str.split('') [, 2, 3, 4, 2, ] [, 8, 4, 7, 5, ] [, 5, 8, 7, 3, ] dtype: object What a good approach to this? Is there a method or function that should be handling this? Thanks so much! Mike -- https://mail.python.org/mailman/listinfo/python-list
Overriding property types on instances from a library
I have some code that makes use of the typing module. This code creates several instances of objects it creates from a library that has some issues. For example, I have multiple list comps that iterate properties of those instance and the type checker fails with: Expected type 'collections.Iterable', got '() -> Any' instead How can I override the type with a hint on a property of those instances? Thanks, jlc -- https://mail.python.org/mailman/listinfo/python-list
Re: issue with seaborn
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: issue with seaborn
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). cheers. -- https://mail.python.org/mailman/listinfo/python-list