Input file is: This code gives output: But I need output should be: Suggest me how can I get this result. Answer This produces the results you want: In case you need lemma:
How to check the folder for file and then read the file in python
I need to read a csv from a folder location, but there is catch in it. It could also happen my other module which writes the csv into that folder fails and unable to export the file, so basically i have to check the folder that if a csv file called “test.csv” exist or not in that folder, if it
Selenium how to select first option if page has multiple select box using python
I have 3 select box’s in my page example : If there has 5 or 6 select box I will always select 1st option, I am unable to do it using selenium. I have tried below code But no any impact, How can I solve this problem ? Answer You are very near of the solution ! See the documentation
Pandas DataFrame: Fill NA values based on group mean
I would like to update the NA values of a Pandas DataFrame column with the values in a groupby object. Let’s illustrate with an example: We have the following DataFrame columns: We’re simply measuring temperature multiple times a day for many months. Now, let’s assume that for some of our re…
Peewee – Recursive CTEs – problem with the documentation example – OperationalError no such column: base.id
I have a problem with Peewee-3 and one of the tutorials in documentation: http://docs.peewee-orm.com/en/latest/peewee/querying.html#recursive-ctes When I’m trying to run this code (nearly exact copy from doc) it’s rising an error: Exception has occurred: OperationalError no such column: base.id He…
sklearn.compose.make_column_transformer(): using SimpleImputer() and OneHotEncoder() in one step on one dataframe column
I have a dataframe containing a column with categorical variables, which also includes NaNs. I’d like to to use sklearn.compose.make_column_transformer() to prepare the df in a clean way. I tried to impute nan values and OneHotEncode the column with the following code: Running the transformer on my trai…
Django rest framework’s StringRelatedField is throwing KeyError
I have the following model classes. and I have imported these classes as following as they are located in a separate package and this is my serializer class and views is and url has the following I am getting the following error I looked into the DRF example and this seems to be a simple thing to achieve. htt…
select top 3 unique items in a list of list
I have a list of items and it outputs a list of list: Is there a way to get the output as a unique list of items that contains the top 3 items from each sublist but also not in the initial item_list? so that the output will look like (in the exact order): or if possible: Answer You must
How to generate a dictionary of lists containing all possible additive and subtractive combinations of a few lists
Say for instance I have a dictionary with string names as keys, and lists as values: I want to generate a new dictionary with keys corresponding to lists that are all the additive or subtractive combinations of the sublists. So this should be the result if we print each sublist in the new dictionary. I don…
Why selenium dont find tag and class
I recently started using selenium and I can’t solve one problem. When I use find_element_by_tag(class)_name or _css_selector raise error: But the element I’m looking for exists. For example: Output: But if I want to find “navbar-brand” class, I can do it. What’s the problem? And …