Skip to content

why I got mixed file path separators?

I am using windows 10 with jupyter notebook under annaconda. from the above, I got / and \ for path separators? I am expecting the result like this How can I modify my codes to get above results? Answer there is no problem working with either or /, python know how to work with those (in windows at least),

Struggles with converting a DBF file to Pandas DataFrame

I’m attempting to work with the Canadian radio station DBF files made public here: https://sms-sgs.ic.gc.ca/eic/site/sms-sgs-prod.nsf/eng/h_00015.html I’d like to read specifically the fmstatio.dbf file into a Pandas DataFrame. I’ve tried the two commonly recommended DBF packages in Python. …

How can I get a socket’s .recv() not to block?

I’m trying to write a simple daemon that listens for orders on a Unix socket. The following works, but the connection.recv(1024) line blocks, meaning I can’t kill the server gracefully: Ideally, I’d like to place all of this inside a Thread that checks a self.should_stop property every self.…

How do I create this function correctly?

I have defined a function string_adder that receives two arguments and returns a concatenated version of both arguments. However, when I run the code, I get this error message: <function string_adder at 0x10cf5bb90> Any advice on what I’m doing wrong? Answer On the line string_adder(“boy&#82…

Calculating hamming distance in a given year

I have a following dataframe: I would like to calculate pairwise hamming distance for each pair in a given year and save it into a new dataframe. Example: (Note: I made up the numbers for the hamming distance, and I don’t actually need to Pair column) I tried something like: Answer The function pairwise…