I have a consumer that consumes from two topics with two different avro schemas. The number of topics can grow in the future, so unioning schemas to read from multiple topics is not scalable. How do I identify/extract which topic the message is from, without deserializing it with the avro schema? Wondering if…
Tag: python
why i can’t predict my x value in linear regression model using reg.predict ( )
Answer You provide a scalar value to .predict method. You need to provide a 2-dimensional array:
How to compare each date in a cell with all the dates in a column
I have a dataframe with three columns lets say I want to compare each date in Date column with all the other dates in the Date column and only keep those rows which lie within 6 months of atleast one of all the dates. Desired Output: I have tried a couple of approches such a nested loops, but I got
Python asyncio, why doesn’t asyncio.FIRST_COMPLETED work as described?
Let’s say I have two functions which return similar results. I want to call both and take the results of whichever returns first. So lets say I have two async functions which wait 5 and 2 seconds like so: And I have a function which calls them like so: As you see the competition function uses asyncio.wa…
serializer not being called AttributeError: ‘str’ object has no attribute ‘_meta’
I modified the Auth User by using AbstractUser Class. Registered it in settings. Everything else is working I can create an instance using the User Model BUT The Problem comes during the serialization. My serializer doesn’t throw any error, but any time I try and use the serializer.data I get AttributeE…
Is EasyOCR license plate recognition dependent on the GPU only?
i would like to know if easyocr for license plate recognition is dependant on the GPU. Im trying to use this script to read the license plate in a image and it’s EXTREMELY SLOW (10+ min). And i just found out the computer i’m using does not have a GPU. Answer As seen on the pypi installation page …
self.array = nums: what is time complexity for assignment of lists in python?
I was solving Dot Product of Two Sparse Vectors (Given two sparse vectors, compute their dot product.) and I got confused about time complexity. For solution: it says in answer that Time complexity: O(n) for both constructing the sparse vector and calculating the dot product. Why time complexity of __init__ i…
Mock.patch returning MagicMock object causing AssertionError?
I have a function that I am trying to test in querySomething.py: And the test file: I am trying to mock the httpClient.get_request so that it gets the JSON file instead of reaching out to the API. We want to test an unauthorized response and a success response which explains the mock_response function. Howeve…
Converting a CSV column into a 1D list and then into a 2D list
Hope you are well, I am fairly new in the python world and the coding world in general. I wanted to test python/panda’s powers and the usefulness of making lists. I have a column called ‘Lines’ in my csv file which reads like this: Lines A,B,C A,D,C B,C,D,E A,B,C,D,E C C,D,E Which I converte…
Pandas (How to Fix): List is actually string and the value of length is misleading
I have a dataframe with a list of years in the first column. A second column shows the number of years listed in each row. Which made me think that the contents of each cell is a pure string. And it seems that way when I checked the type: When I convert the column to list using to_list(), it shows: