« first day (3051 days earlier)      last day (2122 days later) » 
00:00 - 21:0021:00 - 00:00

00:58
Is there a way in pd.read_csv to ignore whitespace after nth occurence? Putting the remaining data in last column
I have a text file where most of the data has 5 fields, but some has 6.
pd.read_csv(filepath, sep='\s+')
01:22
hey guys, im trying to test if arrays in a list are almost unique
I was thinking that there's probably some nifty vector property I can factor into this
Array as in numpy array? numpy.allclose
"Almost unique" is ambiguous
rhubarb
01:49
@pyeR_biz Can you just strip() after reading it?
02:16
@AlexanderReynolds for now, used regex in sep = "\s+ {3}"
 
1 hour later…
03:33
I think this is a dupe of pandas Pandas split DataFrame by column value. If not, the OP is very unclear.
cbg
str.strip() isn't working for me and I am confused
03:53
can anyone help me or look at my code
 
2 hours later…
05:24
Hey Guys, This is Smith. I am new to python. I have a question. I have a function with default argument for ex.,
'def func(storein=""):
if not storein:
store = 'output''
Is it the correct way of writing? or any better way to do this? Pythonic style?
 
1 hour later…
06:48
@SmithDwayne that is common, it is better to explicitly check if it's an empty string. You can also do it with a ternary. storein = "output" if storein is "" else storein
I wonder if it's not just simpler to use something like def func(store="output"):
@AlexanderReynolds NO is!
damnit, thank you.
@SmithDwayne storein = "output" if storein == "" else storein
07:16
default arg sounds more likely
 
2 hours later…
closed
Much obliged
09:40
@AlexanderReynolds: Thank you. It helps a lot. But could you please tell me why is it better to explicitly check?
I want to speed up following code execution:
def occurence3(df):
for ind, row in df.iterrows():
df['DATE'] = pd.to_datetime(df['DATE'])
df['Diff'] = df.groupby('Premises Number')['DATE'].diff(-1).abs().dt.days
return df
09:58
@ParagS pinging people like that is rude, just stop that
if anyone wants to answer they will
Thanks for suggestion.
@AndrasDeak I was trying to get in touch with specific user to begin discussion.
yes, I'm telling you not to do that
@AndrasDeak I got your point, now I am focused on my work
thanks
thank you
10:13
I'm not a pandas guy, but you don't seem to be using the ind or row variables inside the for loop at all, so that looks weird
What should I do after learning the basics of python? Any tips?
@Aran-Fey you mean I should use index instead of any no to refer to a dataframe row/col in for loop
I have no clue what your code is intended to do (and I also don't know pandas), so no, I wasn't telling you to use an index or whatever. All I know is that you have two variables that you never use
Say I want to inherit from 2 classes that don't use super. The easy way out is to call each of the 2 parent constructors explicitly, like so:
class Foo:
    def __init__(self):
        self.foo = 'foo'

class Bar:
    def __init__(self, bar):
        self.bar = bar

class FooBar(Foo, Bar):
    def __init__(self, bar='bar'):
        Foo.__init__(self)
        Bar.__init__(self, bar)
Now wim threatens to have my programmer license revoked for poor programming practices, so I want to rewrite my child class to use super. To do that, I'm going to have to write a FooAdapter. The things I'm having trouble figuring out are:
1) Do I also need a `BarAdapter`?
2) How exactly do I correctly implement the adapter(s) anyway?
class FooAdapter(Foo):
    def __init__(self, *args, **kwargs):
        Foo.__init__(self)
        super(Foo, self).__init__(*args, **kwargs)
^ is that correct?
The child class contructor should look like this btw:
class FooBar(FooAdapter, Bar):
    def __init__(self, bar='bar'):
        super().__init__(bar)
11:02
Cabbage
cbg
@Aran-Fey I got it, I used it without for loop and got ans.
Sorry, what was the original question?
Thanks. you could use numba to speed it up. numba.pydata.org
11:49
I want to select a cell of a column where the column value is 'y'. Say the column name is 'system' in pandas. My code is,
'currdf.loc[currdf['system'] == 'y'].iloc[0]['system']'
any better way to do this? What if no column 'system' value is 'y'? How to handle it?
sorry. In the last question, I made a mistake. Code is,
 'currdf.loc[currdf['system'] == 'y'].iloc[0]['curr']'
@Aran-Fey can't you rewrite Foo and Bar to use super?
Let's assume I can't
hehe
@wim does PEP8 actually say that? Can't find anything in it with a bit of searching
 
2 hours later…
13:43
I don't see it in PEP 8, but "end your text file with a newline" is a common enough recommendation in other contexts
Syntactically valid C programs end with a newline. POSIX defines a line to always have a "terminating <newline> character". Various Unix tools give surprising results if you run them on files without a trailing newline. etc.
Which is all to say, thanks to its ubiquity, the concept has burrowed itself into the collective unconscious, so it's easy to assume its presence in standards documents regardless of whether it's actually in them :>
implicit standard is best standard
@AndrasDeak sarcasm?
Whoops, you citizens aren't cleared to see that. Move along.
14:09
Here's a question I've been trying to answer this morning. You have an equilateral triangle and a point P within the triangle's borders. You continuously apply the "removing triangles" method of Sierpinski triangle generation. Eventually, P will no longer be within the boundary of any of your triangles. Is there an efficient method of calculating how many iterations is required to reach this state?
it will be within the boundary for points lying inside Sierpiński's triangle, right?
Example. The red point is within the boundary for level 0 and level 1 sierpinski triangles. level 3 is the first level where it lies on a white background.
One corner case I have neglected is the case where the point lies on a triangle's corner. If this counts as "within the boundary", then the point is always within the boundary for any arbitrarily high level
I am ambivalent about whether the hypothetical efficient method returns 0 or infinity or nan or whatever in that case
if you want to be "inside" the triangle then it'll probably drop out eventually; I'm not sure if the triangle is an open set but it probably is
there's probably some kind of ternary encoding for points inside/outside the triangle that lets you hone in on which points are left
that might actually help with your question, now that I'm writing this down
I can do it in O(level) time with regular old point-in-polygon checks plus recursion, so I'm trying to improve on that
Maybe I should try to tackle the question in a smaller dimension. e.g. does an efficient method exist for the Cantor Set
for the Cantor set I think so, looking at binary digits or something
14:28
Wikipedia says you can tell if a number is in the Cantor set because it's base 3 representation doesn't have any 1s in it.
Along those lines, though I don't think it helps: For the Cantor set, rebase your numbers from 0 to 1 in base 3. Where base-3 0.1 is decimal 0.33333... In this scenario, the level the number first exits the set is the digit place that... Kevin'd by wikipedia
@Kevin ah, that was it, sorry
of course, since you're cutting out 1/3 in each iteration
You can inspect every digit of a rational number in finite time, if you know how to identify repeating digits. I think this is isomorphic to my recursive O(level) approach.
I do too
My suspicion now is that O(level) is the best you can do. I think you can prove it with fancy information theory techniques. Too bad I don't know any of those.
14:34
pray to the holy Knuth for inspiration
Something something cardinality something pigeonhole principle
This edit makes me laugh. I imagine a /rolleyes emoji is appropriate in the explanation box.
Actually, can you put emoji's in the explanations?
yes, but should not
I expect it supports all of unicode and no other kinds of "rich text"
the edit sandbox probably has an answer
14:41
(or perhaps s/all/the parts that are typically supported by your average browser UI, which includes 🔥, 💯, etc/)
Conclusion: you can put rolleyes in edit messages. cc @piRSquared
cbg \o
🧙🔥🡆📧
☕⌚
m8_
m8_
14:59
Can some explain why this works df = df1.loc[df1['Status1'] != 'No'] but this doesn't df = df1.loc[(df1['Status1'] != 'No') | (df1['Status1'] != 'Yes')]?
Unrelated: A recent answer to a question on the main site suggests doing if my_int in range(23, 42):. They got a couple downvotes and self-deleted. Is there any reason not to do this in modern Python? Membership testing on range objects is O(1).
@m8_ "not works" how?
m8_
m8_
The second just returns the entire df
while the first correctly removes No
@Kevin perhaps they have strong opinions that 23 <= my_int < 42 is better
Reading the question again, OP wants to check my_int against some numbers in that range, but not all. So perhaps the downvotes weren't saying "this is not idiomatic" but rather "read the requirements again"
15:01
@m8_ the latter is doing what it should
'No' != 'Yes' so the second conditional selects those rows
When I am space emperor, en.wikipedia.org/wiki/De_Morgan%27s_laws will be required reading for all citizens
m8_
m8_
Sorry, the column contains No, Yes and other strings. I'm trying to only have rows where the value is not No or Yes
Try switching out the | with &
@m8_ put another way. Let A != B then X != A or X != B is always True
m8_
m8_
and worked...but I don't get why
15:03
Remember that the opposite of a == b or a == c is a != b and a != c. Note especially that the middle operator has changed
m8_
m8_
Maybe it's just too early for my brain lol
thanks
cognate of if x != 2 and 3
@m8_ you're looking for things that are neither 'Yes' nor 'No'... something like None or 'maybe'. The only way to capture those is to insist that your thing is neither 'Yes' nor 'No' "Thing is not 'Yes' AND Thing is not 'No'"... I don't think I'm helping
Perhaps a truth table would be instructive...
x          | x != "Yes" | x != "No" | x != "Yes" or x != "No" | x != "Yes" and x != "No"
-----------+------------+-----------+-------------------------+-------------------------
"Yes"      | False      | True      | True                    | False
"No"       | True       | False     | True                    | False
"Coconuts" | True       | True      | True                    | True
Kevin please tell me your secret of creating charts like that, unless it's constructed by the people of kevins.
m8_
m8_
15:11
Ah, yeah that helps
Discrete math was never my strong suit...
I prefer to fumble around until things fall into place
@MooingRawr I do it in Notepad. I do have a table printing module that I used to debug KevinScript's parser, but for tables of this size it would take just as long to define all the cells in a list-of-lists and call the function, so I don't bother.
@Kevin Proposed reason not to do that: Try 10_000_000 + .5 in range(1, 10_000_000_000)
Ok, I'm trying it. It's slow. This is surprising to me.
Hey guys, a quick question. Pycharm pything IDE recently started showing following doctring format:
example:
def union(set1, set2):
'''
:param set1: a string
:param set2: a string
:return: a string containing
'''
Ah, the docs say that range "[Tests] int objects for membership in constant time instead of iterating through all items." No guarantee about other types.
15:15
Now in this, is ":" before "param" valid? And what does it denote?
To be more specific, why not:
param set1: a string

and why:
:param set1: a string
You'd think that it would test is_integer against floats before actually iterating
@BikramjeetSingh It's valid in the sense that it's syntactically legal Python, because you can put almost anything inside a string literal.
for my_int in (10_000_000, 10_000_000.5):
  print(isinstance(my_int, int) and my_int in range(1, 10_000_000_000))
works great
I don't think Python enforces very strong requirements about what a docstring looks like. For instance, python.org/dev/peps/pep-0257 has two example docstrings with completely different parameter line styles.
No, I misread it, there's only one example that has parameter lines.
@BikramjeetSingh you'll want to pay attention to the docstring format if you want to use a documentation generator like Sphinx. If you do, it will parse the docstring and produce html or some other format.
But anyway, it says "[This] PEP contains conventions, not laws or syntax" which implies that it's not going to police whether your params start with a colon
15:21
This is a good post
747
A: What is the standard Python docstring format?

daouzliFormats Python docstrings can be written following several formats as the other posts showed. However the default Sphinx docstring format was not mentioned and is based on reStructuredText (reST). You can get some information about the main formats in that tuto. Note that the reST is recommende...

I see it now, ":" before "param" is basically a reST format.
Thanks a lot @Kevin and @piRSquared for suggestions on this.
Yes. Some people think its ugly. I agree with them. I use google style and I let sphinx know it. That way, I can read the docstring in the source and the documentation also gets produced.
Theory: the dev team could effortlessly make range.__contains__ do an is_integer check, but they won't because it would encourage people to use range in a way they don't like
Well, truth is, I was lazy... 10.0 in range(1, 20) evaluates to True so to really nail it down, you need to check if a float has the same hash as it's integer counterpart. And that just might be too ugly
for my_int in (10_000_000, 10_000_000.5, 10_000_000.):
  print(
      (isinstance(my_int, int) or hash(my_int) == hash(int(my_int)))
      and my_int in range(1, 10_000_000_000)
  )
hey guys, once I install tensorflow I dont need to be online to use it correct?
15:31
yes
great, i hate libraries that force you to make external calls or host content elsewhere so thats reassring
I'm not confident that hash(x) == hash(int(x))) guarantees that x is an integer, thanks to the possibility of hash collisions. It's a one in a zillion chance, but it's greater than zero.
Unless the hashing algorithm happens to distribute hashes in such a way that no float's hash is ever equal to the hash of its nearest integer neighbor. That's not impossible.
True... but remember the lazy part. I didn't want to really think. What would work? int(my_int) == my_int
(isinstance(x, int) or (isinstance(x, float) and x.is_integer()) and int(x) in range(...) I suppose. Not sure how many of those parens are actually required.
I think all([hash(i) == hash(float(i)) for i in range(10_000)]) is True
15:39
I'm willing to believe that. What I'm worried about is that hash(math.pi) equals hash(3.0), which gives the mistaken impression that pi equals 3.
I read that somewhere that the hashes were guaranteed to be equal for dictionary lookups
mydict[1.0] will always return the same as mydict[1]
Seems reasonable.
I don't know why I thought to use hashes anyway. equality is perfectly sufficient and much more reasonable.
I've been running next(x for x in itertools.count() if hash(x) == hash(x+0.1)) for a minute and it hasn't yielded anything, so maybe the thing I said about hash distribution is actually true
I will require infinite time to confirm it though
I'll be waiting
15:46
Well actually I suppose I only need to test all 2**64 floats
Ask me again in 18446744073709551616 milliseconds
I'm going to take a quick trip at .9c
Most likely by that time I will have mutated into a squid person or a giant brain in an embryonic sac, so brush up on your squidese and brainlang while you're away
pi: I'm back! So what was the answer?
me: Squorsh.
pi: Can you enunciate your chromatophores a little more, please?
Unicode is going to get a lot of new letters when they support cuttlefish language. 16 million colors and 180 angles of polarization of light ought to do it.
wait.wut?! They can control polarization? TIL!
I think so? Where's that wikipedia quote...
> Cuttlefish change color and pattern (including the polarization of the reflected light waves), and the shape of the skin to communicate to other cuttlefish, to camouflage themselves, and as a deimatic display to warn off potential predators.
So theoretically, We could make 3-D televisions with cuttlefish technology
You open up the back and the cuttlefish is smoking a cigarette, saying "eh, it's a living"
16:12
Hello guys
@piRSquared cutiefish!
Yeah, cool but scary. I wonder how they do it, exactly.
Raw gumption
I know that early Liquid crystals where made with cholesterol of some kind, so they might use something similar.
Or that
16:18
> To change colour the animal distorts the sacculus form or size by muscular contraction, changing its translucency, reflectivity, or opacity.
I see, I see, this explains everything (<<< doesn't get it at all)
I saw this cool method of generating sierpinski triangles that you might be interested in.
"Kid produces Sierpinksi Triangles with this one weird trick..."
I appear to have lost the script. Oh well, here's a numberphile video on it: youtube.com/watch?v=kbKtFN71Lfs
I will put it in my cool sierpinski generating methods collection
Here's a script which uses the same method with modified rules to produce fractals.
16:39
Compute Pascal's Triangle, and plot every odd value as an X, and every even value as a space (or O if not using monospaced font) -> wahlah! (as my wife's 3rd graders would say)
Since the sierpinski triangle has zero area, save yourself some time by not drawing it at all
m8_
m8_
16:59
Hey again, quick question...this line of code with groupby and concat values in the Key column: df.groupby(['OrderID','ID'])['Key'].apply(','.join).reset_index(). Can I edit this line to concat the values in the Key into a different or new column?
code will*
Im trying to put the Keys in one of two columns, based on a condition
The fractals I get from the script remind me of julia sets, I wonder if there's a connection.
@Kevin Well, I'm not plotting the area, just the outline, which is infinite (must remember to order more printer ink).
I never knew that Plato's cave had a printer
17:20
cbg
cbg
Question, if anyone knows. can someone tell me the difference between np.mean(somedf['column_1']) and np.mean(somedf['column_1'].values) ?
more specifically, i am getting different results for them. (by a crazy margin)
the latter is the mean of a numpy array, the former might delegate to pandas.DataFrame.mean I guess
i think it does. why would the two be different?
Are all the entries the same datatype?
17:25
nans?
"crazy margin" == "crazy small"?
crazy big. no nans, pretty consistant data. its all loaded in memory as float 32
off the top of my head, dataframes store data column-wise, while C-contiguous numpy arrays are row-major
@ParitoshSingh ah
but its A craptonnn of data
.values removes the axes labels I think, that might have something to do with it.
so my guess is something related to datatypes and buffers going wrong. but thats a grey area for me.
i dont know much there
and even so, i dont understand why the difference in behaviour
17:27
>>> class VerboseDF(pd.DataFrame):
...     def mean(self, *args, **kwargs):
...         print("I'm being meaned!")
...         return pd.DataFrame.mean(self, *args, **kwargs)
...

>>> df
   a  b
0  1  4
1  2  5
2  3  6

>>> np.mean(VerboseDF(df))
I'm being meaned!
a    2.0
b    5.0
dtype: float64

>>> np.mean(VerboseDF(df).values)
3.5
im only accessing 1 column
@ParitoshSingh specific numbers? Number of float32 values and the difference you see
@ParitoshSingh my point was that it's indeed about df.mean
ah i see
hmm. uhm, give me 5 and i can probably try to get exact numbers up perhaps. its on my work laptop
if it's a lot of data then you can accumulate (single-precision!) errors quite easily
and that would be okay too.
the trouble is, the real mean would be somewhere in the ballpark of 5
(values ranging from 0 to roughly 14ish?)
and the pandas mean is giving 0.44
or something like that.
like, it was really wayy off
(or maybe more than 5 min, this takes a while to load )
17:41
Try making an array out of the .values data, e.g b = somedf.values and then print random values to see whether there have been any errors?
the mean behaves quite well when paired with .values. no errors there.
Oh, ok
Per @3141 linked method... Random Sierpinksi
Is this one of those things where "mean" does not always mean "average"
import matplotlib.pyplot as plt
from numpy.random import rand as U
from numpy.random import randint as I
from itertools import islice

def G(P, *V):
    while True:
        P = (P + V[I(3)]) / 2
        yield P

g = G(*U(4, 2))

plt.scatter(*zip(*islice(g, 10_000)), s=1)
17:44
Thanks, did you check out my fractals?
nah, it should be good ol' average.
ooh, data loaded
We're going to find out in twenty minutes that np.mean is the geometric mean or something
Jeez, how big is big?
@3141 yes... messing around as I find time (-:
"In single precision, mean can be inaccurate" - the np.mean docs
Under examples, beneath the first one.
The fractals are pretty cool, and I suspect for some reason that they might be julia sets @piRSquared.
17:49
ok. 629145480 values. no nans. data ranges from 9.5*10^-5 to 16.1074. np.mean with values: 5.678285. pandas mean on the same column: 0.4477
im fine with losing precision in mean calculation too, but i just dont get why the mean gets plain "wrong" in pandas
is column.isna().sum() really 0?
let me run that, but it should be. one sec
>>> 1 - (np.float32(4)/np.float32(3) - 1) * 3
-1.1920928955078125e-07

>>> 629145480 * (1 - (np.float32(4)/np.float32(3) - 1) * 3)
-74.99998569488525
machine epsilon
17:50
its 0
OK
either they sum up in a different order or either of them use a different dtype for accumulation
rhubarb for a while
To be fair, the example provided in the docs is vastly innacurate
amusingly enough, we can actually see the effect that float 32 vs 64 has. running np.mean(df['col'].values, dtype = "float64") gives 5.67829171...
I'd be interested too see their method of calculation
17:53
so, the docs are spot on in that regards, and that kind of difference makes sense to me too.
its just the pandas mean specifically thats just bonkers
Yeah, for sure.
I might check out the source.
18:05
You could validate results using the statistics module - it is very careful about computing mean without overflowing
Or you could use a sheet of paper and a pencil.
Shouldn't take you 2 minutes.
Except for the part where there are 629145480 values
Just get a hundred million of your friends to help. Many hands make light work.
Not to worry, I have a calculator somewhere
You're assuming I have friends @Kevin
haha
oh god, i think statistics.mean cant handle these many values
heres to praying it manages to not die :P
18:16
@m8_ I made a test drive so now I can test some stuff may take me a little bit though
Be patient, I believe it is not overly fast
yay, it churned out an answer!
Hmm, in the absence of friends perhaps you can get a hundred million enemies to help. But how do you prevent maliciously wrong answers? Maybe some kind of blockchain...
or maybe i would need to build a loaded exe that holds their computer hostage and i can threaten them with "consequences" if i find out they misled me.
Now to just get that exe going and find 629145480 "frenimies"
Nah, a blockchain wouldn't work. I could try asking nicely.
18:23
Get ten enemies to do a single calculation independently of one another, then average their results together. If half of them maliciously add one to the result, and half of them maliciously subtract one, then the average will be the correct answer.
closed now
Get an infinite number of enemies to work out one digit of the answer. Collectively, the ones you assign to say, the first digit, will return every number for it except for the right one, presuming they randomly choose a false number. The true value of the digit will be the one number they dont return.
wim
wim
@Aran-Fey No I don't. Calling the 2 parent classes inits explicitly is fine by me.
@AndrasDeak yes..?
18:30
that's not PEP 8, that's a linter, right?
wim
wim
it's pycharm's PEP 8 inspections
my point exactly
wim
wim
Well, it could certainly be the case that PyCharm is doing something stupid here.
I just tried looking it up in the actual PEP and couldn't find it
wim
wim
maybe it was there in a previous version of PEP 8 and got removed?
18:32
Could be. I can also understand if it's a rule one should keep with or without PEP 8, and Guido probably wants it there, I was just curious about the law
wim
wim
The warning number was W292
One of the reasons is that if you cat a file to stdout, and there is no newline at end, your shell prompt will be printed at the end of the last line and it's a minor annoyance.
yup, I'm familiar with that
wim
wim
the historical reason is for #include macros in languages with a preprocessor, which doesn't really apply to python
I'm doubling down on "it's a standard in a bunch of other contexts, so everyone insists that it should also be applied to Python"
wim
wim
but in C++ for example you could #include another file and make a syntax error because the end of the last line got stuck together with the next line of the file which is doing the #include
ufff, hard to explain if you've never had it happen to you.
18:37
@3141 v
from numpy.random import randint as I
from itertools import islice

def J():
    a = np.array([[-1, 0], [0, 1], [1, 0]])
    x = np.zeros(2)
    while True:
        x = 2 * a[I(3)] - x
        yield x

fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111)
ax.scatter(*zip(*islice(J(), 100_000)), s=1)
wim
wim
I suppose "Python doesn't have a preprocessor" is a shakey claim, given the way the coding declaration and future statements work it's a bit like a preprocessor.
m8_
m8_
@Error-SyntacticalRemorse, no worries. I appreciate the help!
That reddit post is from four years ago. PEP 8 says its post history is "05-Jul-2001, 01-Aug-2013", which means it was last changed 5.5 years ago. I'm inclined to say that the OP of that post merely assumed that PEP 8 recommends newlines at the end of the file, when it doesn't actually.
Nice @piRSquared, reminds me a bit of the dragon curve
The symmetry on these is interesting too.
18:45
Here's the situation as I see it. PEP8 does not currently require newlines at the end of a file. Several respectable code style tools do require newlines, and their messages suggest that PEP8 also requires it. So now we are trying to distinguish two possibilities: 1) PEP8 used to require it. 2) PEP8 never required it, and the rule appeared when one code style tool dev pulled it out of nowhere and everyone else copied him
I'm a regular Jackson Pollack
from numpy.random import randint as I
from itertools import islice

def J():
    a = np.array([[-1, 0], [0, 1], [1, 0]])
    x = np.zeros(2)
    while True:
        x = .01 * a[I(3)] - x
        yield x

fig = plt.figure(figsize=(15, 15))
ax = fig.add_subplot(111)

j = J()
for c in 'bgrcmy' * 10:
    ax.scatter(*zip(*islice(j, 5_000)), s=1, c=c)
I looked at the history and I don't think PEP 8 used to require it
if they'd have put it in later it would probably still be there
guess we could search the python mailing lists...
wim
wim
2) seems likely.
the shame
wim
wim
I suppose the pep8 you get with pip install pep8 is actually completely bogus/unofficial
18:48
Credits

Created by Johann C. Rocholl.

Maintained by Florent Xicluna and Ian Lee.
it's not like they're trying to sound official
> This package used to be called pep8 but was renamed to pycodestyle to reduce confusion.
yup
wim
wim
the smocking gun.
Pretty nice @piRSquared. I have loads of my favourites saved somewhere.
I don't particularly mind code style tools suggesting a final newline, but I'd prefer a correct citation
Less "PEP 8: blank line", more "POSIX standard: blank line" or w/e
wim
wim
19:00
the only code style tool worth using is black
all the others can go in the trash
I don't need a linter. My mom says that my code is beautiful and special because I made it
wim
wim
# This unique piece of code is produced with an artisanal process. Any defects are a natural part of it.
The cyclic import is a commentary on man's inhumanity to man
@m8_ I posted a new solution that is actually tested.
m8_
m8_
19:11
@Error-SyntacticalRemorse great! let me test it out.
@m8_ no problem but you should probably delete all the old comments on that answer now. It currently acts as cluter
Good luck :)
m8_
m8_
Will do, thanks!
19:31
Is the code in stackoverflow.com/questions/54833870/… some kind of nonstandard Python dialect? Is... Is this a pycharm thing?
Is this jupyter? What's the !python notation? — Adam Smith 40 secs ago
jupyter was my next guess :>
20:05
@Kevin Yeah, same with % and %% stuff, if you ever see that.
I ended up writing an answer, with a plea to use regular old Python syntax instead, but I 95% expect a reply like "I'd love to use regular old Python syntax, but unfortunately I can't because Venus is in retrograde"
5
dang you venus...wait, what?
@Kevin 😂
Unrelated: a recent question asks, "how do I add one to my variable b? I tried i += 1 but it doesn't work". My theory: they read a tutorial saying "to add one to a variable, use i += 1" and assumed that this command would add one to whatever variable it thinks you mean
Python is good, but it's not that good.
Surely in the 21st century computers should be able to figure that out; how hard can mind reading really be? smh
20:11
Hang on, can Venus be in retrograde? that might only be a thing for planets with orbits larger than Earth's.
Mercury retrograde is a thing, but I don't think I ever heard of Venus retrograde
whatchu talkin about @Kevin
class Adder:
    def __add__(self, amount):
        for key in globals():
            try:
                globals()[key] += 1
            except:
                pass
en.wikipedia.org/wiki/Apparent_retrograde_motion lists the retrograde of the seven other planets (sorry pluto ;_;) so I guess it is indeed a thing
its two different types of retrograde
In that case, maybe I'm thinking of the other one.
20:15
i = Adder()
i += 1
done.
:D
Outstanding.
oops, should be += amount
(because thats the problem with the above code)
OP ended up not using regular old Python syntax. To be fair, it would actually require non-trivial effort to do so. So I can't really blame them for going with the quick-n-dirty approach.
I wonder what would happen if you tried to make a quick-n-dirty SOAP implementation
I also wonder how much the average quality of jokes goes up when I'm not here
20:43
@piRSquared Do you think it is worth adding a section or small part to your pivot canonical on how to pivot when there is no column identifier within group, but one needs to create it (with a .groupby(group).cumcount()). Or perhaps there's a good dup or post to link already. I just feel like most users asking for this wont figure this out from the pivot canonical, but having a one line .groupby.cumcount doesn't really warrant a new answer.
@Aran-Fey That would leave no time for REST!
And yeah, I try resetting the average down to zero sometimes :-p
This is productive programming cabbage after all, so absolutely no joking, by design
*productive*
The stars are for emphasis you see
@ALollz that is a good idea.
20:52
Is there a way to test if it is avalable on a system without a try/except?
for science? cause try except works really well for testing imports
@Simon "On a Unix-like system, random bytes are read from the /dev/urandom device. If the /dev/urandom device is not available or not readable, the NotImplementedError exception is raised." so you can check if that device exists.
what is the slickest way to convert an array of complex to a 2d array with reals in the 1st column and imaginaries in the 2nd column (Numpy)
@Simon much better to just use a try/except though IMO.
np.exp(np.linspace(0, 2 * np.pi, 11)[:-1] * 1j) gets me the 10 complex points that make up a regular decagon
dec = np.exp(np.linspace(0, 2 * np.pi, 11)[:-1] * 1j)
np.column_stack([dec.real, dec.imag])
20:59
b = np.array([a.real, a.imag])
?
Gets me what I want but I feel like there should be something better.
So neither random or secrets provides anything to check @AlexanderReynolds In which case a try/except does seem to be the best option
wim
wim
duplicate manager stopped working
how to debug it ...
@Simon You can just check it manually with a path.
00:00 - 21:0021:00 - 00:00

« first day (3051 days earlier)      last day (2122 days later) »