« first day (3894 days earlier)      last day (1037 days later) » 

6:28 AM
cbg
 
 
1 hour later…
cbg-ning
 
9:03 AM
with Cabbage(timeofday="local") as cbg:
    cbg.greeting()
 
9:14 AM
@tripleee context manager at its best XD
 
9:25 AM
can anyone help me in finding the similar text or keywords from a string using a python
 
9:37 AM
@Hedge that's fairly vague, but given the information you have provided, I am guessing you might be looking for fuzzy matching or tf/idf
fuzzy matching / edit distance helps you find words which are not identical, but lexically similar
TF/IDF finds texts containing many similar words to a reference sample, so this is useful for various types of information retrieval and document classification tasks
if your definition of similarity is something else, perhaps try to explain in more detail
yet another common question is semantic similarity, like chair <-> stool
if that's what you need, Wordnet is a useful resource, though by itself not at all sufficient; not familiar enough with the domain to recommend any particular Python library
 
10:02 AM
@tripleee i have written the code using fuzzywuzzy but am not really satisfies with that,

example:

String=TYPHOO [T] [MAINPK] 25 NO CDBOX GREEN TEA

Keywords:Green Tea,Greentea,grentea, green tea 25

i need to get the list of that has the mentioned keywords
 
that's terrific; if you need help with the code you have written, you need to show it to us
 
i need to know is there way to do it
some library or model for it
 
you already found one; how is fuzzywuzzy not fulfilling your requirements?
 
am not getting the similar strings
40% is the accuracy
import pandas as pd
from fuzzywuzzy import process, fuzz

master=pd.read_excel(r'C:\\NL123\MOPM.xlsx')
Dat=pd.read_excel(r'C:\\NL123\Comp.xlsx')

actual_SU= []
similarity = []

for i in Dat.SKU:
        ratio = process.extract( i, master.SU, limit=1,scorer=fuzz.token_sort_ratio)
        actual_SU.append(ratio[0][0])
        similarity.append(ratio[0][1])

Dat['actual_SU'] = pd.Series(actual_SU)
Dat['similarity'] = pd.Series(similarity)

Dat.to_csv(r"C:\\NL123\Comp_output2.csv",index = False)
 
why do you keep removing your code? finally something useful we can look at
you can edit a chat message up to (IIRC) two minutes after you post it
without access to your data it's hard to say anything more though
I'm guessing the problem is that you are looking to extract a substring from one or more longer strings, so you will probably need to define a function which matches substrings of a particular length
(not sure if there is one in fuzzywuzzy; by quick glance it seems there isn't)
 
nhm
10:25 AM
I have two arrays A & B of floats of size (10000000, 3) and (1000000, 3). B is part of A. Now I need to find indices of A corresponding to B values. Since it involves float comparision. I don't know how to do. I had posted this as a question. I got nice and optimised answer but it works only if elemets of B exactly match with A.
Solution given for my question is as follows
table = dict()
for i in range(A.shape[0]):
key = tuple(A[i])
if key not in table:
table[key] = i
extract_BinA = np.ones(B.shape[0], dtype=int)*-1
for i in range(B.shape[0]):
val = tuple(B[i])
if val in table:
extract_BinA[i] = table[val]
 
hi
 
@Hedge not too stellar either, but something like this? replit.com/@tripleee/SnivelingJaggedFeed#main.py
the logic skips shorter matches if it finds a longer one, but it still outputs junk when matches are extracted at different offsets
 
uhh what?
 
it expects the input string to be reasonably normalized
 
where is it
I don't understand complex codes
because i am still learning
 
10:37 AM
@nhm where is your question?
 
this is his question
 
@Wolf are you serious? we can scroll back ourselves
the question they are talking about is apparently this one stackoverflow.com/questions/67959516/…
@nhm not my field of expertise, but my suggestion would be to accept the answer you got and ask a new question with your actual requirements and enough data to reproduce it
 
nhm
Thanks I will do that
 
@tripleee ok
 
@Hedge maybe also look at stackoverflow.com/questions/17740833/… which seems to be the same problem as yours
 
nhm
10:44 AM
Thanks will look in to it
@nhm I edited the answer to provide examples covering this case — Jérôme Richard 14 hours ago
 
sorry nvm, replied to the wrong post
 
@tripleee let me check
 
 
3 hours later…
1:58 PM
@Wolf please make a very strong effort to be more constructive. Tip: "uhh what?" when nobody is talking to you is not constructive. Reposting another user's message is not constructive. "i am still learning" is not an excuse to be a nuisance.
 
Is calling super() short for superclass?
 
The name super is derived from superclass, yes.
 
Nope. It actually gives you the next class in the MRO
(well, not really, but essentially)
 
In a way, the MRO is packed full with superclasses. :P
 
I asked because I see
 
2:06 PM
...true, but they're not necessarily superclasses of the current class
 
class A:
    pass

class B(A):
    def __init__(self):
        super().__init__()
but I think it is same as
class A:
    pass

class B(A):
    def __init__(self):
        A.__init__()
So my understanding was super() refers to the inherited class(superclass).
@Aran-Fey What is MRO?
 
That's no longer as simple with multiple inheritance. Python’s super() considered super! is a good read on that.
 
@CoolCloud Nope, they're not the same. Try this with both versions:
class WellHelloThere(A):
    def __init__(self):
        print('Hi!')

class Magic(B, WellHelloThere):
    pass

Magic()
@CoolCloud Method Resolution Order. Basically a list of parent classes. Whenever you access an instance/class attribute, python scans each class in this list for that attribute
 
@Aran-Fey Ah, it does not work in the version without super().
 
For example:
>>> B.__mro__
(<class '__main__.B'>, <class '__main__.A'>, <class 'object'>)
And the interesting thing about it is that you can insert classes anywhere you want. For example, in Magic's MRO, WellHelloThere appears between B and A
>>> Magic.__mro__
(<class '__main__.Magic'>,
 <class '__main__.B'>,
 <class '__main__.WellHelloThere'>,
 <class '__main__.A'>,
 <class 'object'>)
That's why hard-coding the base class is not the same thing as using super
 
2:15 PM
@AndrasDeak ok
 
@Aran-Fey Ohh I get it, thanks :D
 
late morning cabbages, folks
 
@MisterMiyagi Nicely written!
 
2:32 PM
I've been writing a parser for the MS-NRBF data format. It was pretty rough going for the day and a half before I discovered the format had a name and a public specification.
 
Yeeeeaaaaaah, that probably helps
 
Prior to that I was reading through the source code for the .NET core engine's NRBF parser, which conveniently has zero mentions of the name "NRBF"
Their implementation is clean and correct and incomprehensible. They try very hard to avoid recursion, and in the process end up reinventing the concept of a call stack, once or twice.
A reasonable precaution when writing something that needs to work perfectly for a million developers, some of whom have users that actively want to destroy them. But my scope is much smaller, so I think I can have a little recursion, as a treat
 
Avoiding recursion pretty much means you push your parameters onto a LIFO stack, no? Doesn't seem like a big deal
 
2:47 PM
Sadly my dream of a pure functional recursive parser with no global state has already been dashed. thanks to 2.5.5 ObjectNullMultiple, which means "the next N times that the parser tries to read a record, instead return null".
So now I have a global virtual_null_records_waiting integer that I have to check at the beginning of each parse_record call. It wasn't difficult to implement, but I shed a tear at the loss of context-free-ness.
@Aran-Fey In principle yes, but the spec has a handful of quirks (like ObjectNullMultiple) that makes the state-and-parameter tracking classes rather hairier than they ideally should be
 
3:10 PM
morning cabbage
 
3:35 PM
its not morning
 
Morning is a state of mind
 
@Wolf it is somewhere in the world
 
 
2 hours later…
5:41 PM
I wrote a decorator that logs a message every time I enter or leave the decorated function. It's been quite helpful for visualizing the path of my code, although it does tend to write a 30 MB log file for a 500 ms long program.
 
5:54 PM
Is that even practical anymore at that point? Finding interesting bits in a 30 MB text file ought to be harder than triggering a conditional breakpoint
 
90% of the time it's no better than a breakpoint. But I found it valuable every now and again, when my program crashed and the root cause wasn't in the current call stack.
#consider the toy example:

def f():
    a()
    b()

def a():
    do_something_dumb() #this will cause a problem lateree

def b():
    do_something_with_data_from_a()

f()

#if this program crashes inside `do_something_with_data_from_a`, then the call stack will not reveal the existence of `do_something_dumb`. But the function executor log will show:

<called: f()>
    <called: a()>
        <called: do_something_dumb()>
        </called: do_something_dumb()>
    </called: a()>
    <called: b()>
You're correct that you're not likely to find much useful data in the middle of a 30 MB executor log. But most of the time, the troublemaking code path was close to the end of the file.
I will say that just once I did find a useful diagnostic clue in the middle of the log, when I was trying to figure out if my buggy function was always crashing, or just crashing with particular inputs. By ctrl-F-ing for <called: my_buggy_func, I was able to find instances where it ran successfully, and find a pattern among which inputs worked, and which didn't
 
6:27 PM
How do you check if a string is in a dataframe's series?
It seems you can check if an integer is in it, but it returns False if it's a string
Ohhh has to be df_filtered['nid'].str.contains(df_filtered['nid'][3]).any()
Been struggling merging 2 dataframes and I noticed the problem was with the datatypes of each cell. Always thought if the dtype of a column was object everything would be converted to string. But realized I was trying to merge int on string even when both columns were of object dtype
Explains why df_filtered = df_filtered.astype({'nid': 'object', 'skuId': 'object', 'Category': 'object'}) didn't convert each cell to a string and df_filtered = df_filtered.astype({'nid': 'str', 'skuId': 'str', 'Category': 'str'}) was the one I was looking for
 
6:57 PM
Hi All, is there any function in python or etree which can search for duplicate node based on specific attribute value and copy some child elements to it?
 
@Pherdindy "Always thought if the dtype of a column was object everything would be converted to string." But the defintion of a DataFrame is an ordered collection of columns of different types, per definition. If they were all converted to one data type, it wouldn't make the DataFrame efficient.
And why strings? Why not ints, or other objects?
 
Only learned now the dtype of object can contain a mix of strings and numeric values always thought if it was classified as object it would be string-like so I converted all to object instead of string. Didn't know the difference lol
the nid, skuId, and Category columns is more of a name/identifier so I felt it was more natural to set it as a string
nid and skuId is always numbers though not sure if I should use int instead. Is it more efficient to do that?
 
7:13 PM
@JossieCalderon because int has multiple defined types in the context of numpy arrays
 
@Pherdindy How is the nid and skuId interacting with other parts of the code?
 
df_filtered = pd.merge(df_filtered, df_merged, on=['nid', 'skuId', 'Category'], how='left') I use it here
 
I think it was an easy enough mistake to make, tbh. At least it's been identified :)
 
I was wondering why I as getting an empty dataframe on something I was expecting to have values. The problem was the rows of df_filtered['nid'] was of str type and df_merged['nid'] was of int type. Thought I would resolve any issues when I used .astype('object') initially
@roganjosh Yeahh lots of stuff to learn still :( investing loads of time but really optimistic on the script
 
7:44 PM
@roganjosh Use an ndarray.
@Pherdindy It's better to filter the first two as int if that's all you're expecting.
 
@JossieCalderon I don't need to. pandas already does that for me under the covers. I'm just suggesting why an int column wouldn't have an object dtype, or why someone would assume it would
 
 
2 hours later…
 
1 hour later…
10:50 PM
@Kevin I take it being robust to malicious/stack-attack input an important requirement for them, then. Do you have a link to their call-stack reimplementation?
@Pherdindy No. In pandas 'object' is a generic container-class for any arbitrary Python object. They could be homogeneous (e.g. all strings) or heterogeneous (e.g. floats with NaNs, or arbitrary Python list/object). In pandas 1.x if you know the dtype of a column you;re reading in (e.g. all-string), you can specify its dtype in pd.read_csv(..., dtype)
@Pherdindy pandas also has a Categorical type (since 0.23) and again you can specify that as a specific's column dtype at read-time, although that may be too early (e.g. if we later want to merge other categorical values or columns, before (re)declaring it as categorical with all its levels known)
All that stuff is new and therefore a bit buggy. The doc, github issues and cookbook are fairly behind on covering them.
@Pherdindy No, .astype('object') doesn't solve problems, it throws away any dtype-specific comparison methods etc so it's useless. Comparison methods on 'object' are useless; it's just a lowest-common-denominator dtype, nothing more. If you want to compare rows of int and string, recommend you make them all 'string'. You can do that in the original epd.read_csv(), you can even override the dtype so that columns that would be inferred to be int instead get read in as 'string'.
If this doesn't solve your issues then please post an MCVE here.
 

« first day (3894 days earlier)      last day (1037 days later) »