Any idea why: self.assertEqual(len(get_count(['','','somevalue'])), 1) is expecting 0 instead of 1? get_count returns list(filter(None, string.split(',')))
I have values like [105.32043301] [-71.08949795] [62.54161414] [114.1538528] [-16.35550116] [25.38564488] [-47.17892941] [-47.82122656] [25.6134267] [178.07654254] [23.77805946] and I need to store it in an array but whenever I do this array = [] and append to it I get [array([105.32043301]), array([value1]), how do I get a simple array, I believe `array = []` is a list I suppose?
user11282064
05:12
Hi all, I need an urgent help on executing Hive query using Spark. The query is "SELECT MAX(date) FROM schema.tablename". Here, the table is not regular table, it is a view table. when I run this query in my Python script using Spark engine, I get an error. Kindly tell me how this can be solved.
@AshwinPhadke Can you clarify what you want? Do you need a array([105.32043301, -71.08949795]) (numpy array) or just a [105.32043301, -71.08949795] (list)?
user11282064
is there any way to get help/solution for my question posted here? I am struggling with this for past 2 weeks, which has to be completed soon. Please help me on this
So he claims that having the proto files inside allows you to just git clone and then you dont have to compile the things again. I mean I see the appeal kinda, but it also feels wrong. The artifactory thing somebody posted yesterday is a much better way to go, but I don't think we have the scale to justify it. Well luckily there are different changelists in pycharm
Ugh, pycharm automatically display != as another symbol. It's weird
@Hakaishin I'm not a fan of that beautification. I think that new char is also only 1-char wide, so visually I have to re-look at it to make sure it's what it's supposed to be
@Hakaishin does it also beautify >=, <= and == ?
(beautify is the wrong word here, coz normally beautifying/prettifying code is a good thing)
Hey guys so I am busy working on my first scraper and working through a tutorial but found that it isnt adding the items to the dataframe. I have played withit individually before writing the entire scrape code which works with taking the correct items, but i think it is how I am saving each to the df at first i tried
@aneroid @Hakaishin they are called ligatures, there should be settings to turn them off, or fonts that don;t support them. I personally like them a lot, in particular because I let black do my space formatting anyways
@Kwsswart good self-catch. df = df.append(...) since .append() returns a new dataframe. it's not like Python's list.append which appends to the list in-place.
@Kwsswart consider enabling syntax-highlighting when you upload the paste - under "syntax" select one of the Python options
@aneroid thanks mate changed that seems I have got i something else as went placing prints throughout here dpaste.com/49NNP5FPQ and the start and links printing but not posts... is it possible that the site itself may be blocking the cumulative scrape? as when scraping a single time with the functions dpaste.com/2KQ9D2L3M it worked but now isn't
hey, I'm facing an issue with socket io , could anyone help?
I keep getting this error even though the version is satisfied.
`The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO)`
@Arne when in code, hard-pass for me. going through this only helped strengthen my opinion - betterwebtype.com/articles/2020/02/13/… the only one which is okay is the => arrow on the first line of each snippted. hard pass on the rest
@Kwsswart no*, that's literally what captchas are there to prevent
@Hakaishin maybe an .idea folder that overwrites global settings was committed to the repo? if it's not that, I'd just accept it as one of life's mysteries
@aneroid Damn well atleast I have an idea of how web scraping works ^^ got my second interview later for a junior python developer position and within the job description one of the responsibilities would be to build scrapers so thought would try
@Kwsswart consider lowering your scrape rate. wait 10-30 secs between each. and before that, wait 15 mins to an hour for your IP to probably be un-blocked
It's like if my files start wit foo_xxxx.py I want these set of settings if they start with bar_xxxx.py I want completely different settings... I don't see why this was split into two places for library files but whatever
@Hakaishin if the prepared statement uses user-input values in the "wrong places" then it's still vulnerable. what you need to do is have placeholders.
they use the library but only use the .execute method that expects a query, it seemed unproductive from the start, might as well call the REST endpoint and save a dependency
@inspectorG4dget well they do ask me that sometimes as well. Even for the simple stuff. For example the other day my friend's PSN account got hacked and he didn't know how to start a live chat with Sony. I sent him the link and everything but I ended up doing it for him
but tbh i do actually like it. It makes me keep in touch with old friends
yeah, I'm not exactly complaining. I have some technically capable friends, and only a VERY select subset of the remainder have the "ask me to call customer support" privilege
so I usually go the teaching route - "you're going to learn this now so you don't need to ask me next time". But I do have some friends who can't grok tech (beyond click on this series of buttons). For them, I either explain the recipe (and am never bothered again) or I just do the thing (which I'm called to relatively rarely)
hey guys, stackoverflow.com/questions/66412420/… its my question on main, eligible for bounty in 1 hour, I dont think it is breaking rules by too much, can anyone suggest why it got no attention?
Guys, is there a clean one/two command way to take a variable and: if it is a list (of strings here) return itself, if it is a single string return a list with that string in it. It's easy to see a method for doing this but I figured there might be a more pythonic way
@python_user yes, you have a reasonable MRE with some additional steps needed by anyone who is curious to set it up. It seems like you can't do much more really.
@skyler perhaps you would be interested in the expression form of a conditional, a if b else c, which in this case would look like my_function([variable] if isinstance(variable, str) else variable)
That said, ideally you would not have a variable that is sometimes a string and sometimes a list of strings. Even though Python is dynamically typed, most of the time you want a variable's type to stay the same throughout its lifetime, across all branches of your code
we do see pandas kind of regularly do something like this, for columns to do operations on it accepts a string for a singular column or a list of strings
I see this kind of thing most often as a parameter that will allow multiple types. I assume that under the hood it has code that massages all values to a uniform shape, similar to the suggested if statement earlier.
For example there's a good reason that json.dump accepts a list or string or dict or number, and that reason is "because it would be a pain in the butt if there were four functions"
[variable] if isinstance(variable, str) else variable is about as easy as you can make it
"seemed common enough" -- perhaps it is in beginner-to-intermediate code, but not so much once you get in the habit of strong typing best practices
I'm also mildly curious how Pandas does it. Do you know the name of a specific function that accepts a string or list of strings? I could look up its implementation.
Parameters ---------- func : callable A callable that takes a {input} as its first argument, and returns a dataframe, a series or a scalar. In addition the callable may take positional and keyword arguments. args, kwargs : tuple and dict Optional positional and keyword arguments to pass to `func`.
@Code-Apprentice the pandas groupby function is an example of a function that takes a column (as a string), a list of columns (as a list), or even a series (of length equal to the length of the dataframe)
the third case it does probably have diverging behavior, but the first two are almost identical in many ways so it probably just treats the string as a list a somewhere early in the code
@Skyler ok, thanks for the explanation. I didn't look very closely at the github link and your quote from the docs didn't include those details. So I was confused.
and yah, turning a single item into a list with a single item seems easy enough so that you can treat both cases similarly.
but man pandas can be convenient sometimes, like I was asked to write a data splitter/merger/updater script for several datasets, and they waited until after I finished everything to mention that some of the datasets have no unique identifier/key columns
luckily though I had just 1 function that I had to do anything more then a minor rewrite because pandas can pretty gracefully use a list of columns to create a unique descriptor
the one thing I despise about their codebase though is that so much of their code is built to fail silently
just add a log entry somewhere and chug on, and its not even any kind of online application
which would be fine if they were doing a ton of parallel operations, but so much of the code operates in serial that having to fish for a failure that happened 80 steps ago and may not even be where the error log spots it is joy inducing
@Code-Apprentice just crack the head open at that point
basically any time I adopt a bit of their conventions to their code it takes 5-10x the time to debug
so now i build everything that can be reasonably done out at the module level before pulling into scripts where they can just nod and accept my test code coverage as a verification of it's functionality
on another topic...anyone here familiar with Swagger UI? I'm using it to generate docs for my rest endpoints in a Django app. The "Try it out" buttons aren't quite working because every response comes back with "Authentication credentials were not provided." So now I'm trying to figure out how to include a token in the example requests.
@python_user if you are just interested in knowing why the loop = ... works and the asyncio.run does not, that is straightforward to answer. If you are wondering how to fix it, that is probably more complex – my hunch is that the library is simply bugged for that invocation. Deterministic closing with asyncio is a pain.
tbh you can see a big difference between new specifications they asked me to create vs stuff they asked me to refactor. A lot of tied hands on design choices and way too much hardcoded stuff for a "refactor"
@MisterMiyagi the result I showed you is the one I need to store as a list in the variable "need_the_result_list_here" which comes from doing a dot product of abc and xyz[i, :].
@MisterMiyagi In your answer, you say "the event loop is not available for cleanup once main finishes". What I don't understand is why anything would need to be executed after main finishes. The Reddit object was already close()ed, so what's left to clean up? Is that just a bug in asyncpraw?
elders: I come seeking best-practices wisdom for maintaining a database. When a live change is made to the database, should Option1: the original schema.sql be changed and pushed to VCS, or Option2: should the changes be saved in updates.sql and pushed to VCS separately?
Are you planning ahead for any future changes? Say update_schema01.sql through update_schema10.sql for each of the next 10 releases?
If so, I suggest leading digits for sorting and more descriptive names: 01_initial.sql, 02_add_foo.sql, 03_move_bar.sql, etc.
A bash script like you are thinking will be helpful in rebuilding a database from scratch. You also should consider how do you know which updates need to be run against the current production that already has some of them applied.
and what if you need to roll back one of the updates