[Solved] Why fuction’s not returning value? [closed]

Your update2new function definitely returns something: def update2new(src_dest): print(“Hi”) fileProcess(src_dest) os.remove(‘outfile.csv’) os.remove(‘new.csv’) return src_dest But you don’t capture it in your main: def main(): print(“<——Initializing Updating Process——>”) srcFile=”abc_20160301_(file1).csv” update2new(srcFile) #the return is NOT captured here print(‘\nSuccessfully Executed [ {}]……’.format(str(srcFile)),end=’\n’) print (“OK”) Change it to: def main(): print(“<——Initializing Updating Process——>”) srcFile=”abc_20160301_(file1).csv” srcFile = update2new(srcFile) #get the … Read more

[Solved] I am writing a program which adds numbers inputed by the user and then outputting the total. With the total how can i output all the inputed numbers

I am writing a program which adds numbers inputed by the user and then outputting the total. With the total how can i output all the inputed numbers solved I am writing a program which adds numbers inputed by the user and then outputting the total. With the total how can i output all the … Read more

[Solved] comparing price and quality labtop in list with python

i solved it: number_of_laptops = int(input()) list_of_prices = [] list_of_qualities = [] for i in range(0,number_of_laptops): inp = input() numbers = [] numbers = [int(s) for s in inp.split() if s.isdigit()] list_of_prices.append(numbers[0]) list_of_qualities.append(numbers[1]) def find_better_lp(number_of_laptops): if number_of_laptops == 0: return print(“empty list”) for i in range(0,number_of_laptops): for j in range(0,number_of_laptops): if((list_of_prices[i] <= list_of_prices[j]) and i … Read more

[Solved] How can I impute values to outlier cells based on groups? [closed]

Using the following answer from n1k31t4 in: https://datascience.stackexchange.com/questions/37717/imputation-missing-values-other-than-using-mean-median-in-python I was able to solve my problem. df[col]=df.groupby([‘X’, ‘Y’])[col].transform(lambda x: x.median() if (np.abs(x)>3).any() else x) solved How can I impute values to outlier cells based on groups? [closed]

[Solved] Python 3.x AttributeError: ‘NoneType’ object has no attribute ‘groupdict’

Regular expression functions in Python return None when the regular expression does not match the given string. So in your case, match is None, so calling match.groupdict() is trying to call a method on nothing. You should check for match first, and then you also don’t need to catch any exception when accessing groupdict(): match … Read more

[Solved] Create condition that searches between two different WHEREs in the table

You can do the test for whether it’s home or away in the query itself. cursor.execute(“”” SELECT CASE WHEN robot_on_her_island = ? THEN ‘Last_War_on_her_island’ ELSE ‘Last_War_on_island_away’ END AS which_island, points_war_home, points_war_away FROM war WHERE ? IN (robot_on_her_island, robot_on_island_away) LIMIT 1″””, (select_robot_on_her_island, select_robot_on_her_island)) row = cursor.fetchone() if row: which_island, points_home, points_away = row if which_island == … Read more

[Solved] record a web page using python [closed]

For opening a specific URL, you could use the module “webbrowser”: import webbrowser webbrowser.open(‘http://example.com’) # Go to example.com For recording the page you could install the modules “opencv-python”, “numpy” and “pyautogui”: pip3 install opencv-python numpy pyautogui And then use them all to get the final code, which could look something like this: import cv2 import … Read more

[Solved] ValueError when defining a lambda function in python

You have a bunch of 1000 element arrays: In [8]: p.shape Out[8]: (1000,) In [9]: K.shape Out[9]: (1000,) In [10]: R.shape Out[10]: (1000,) In [11]: np.minimum.reduce([p, K, R]).shape Out[11]: (1000,) In [12]: Vl(p).shape Out[12]: (1000,) In [8]: p.shape Out[8]: (1000,) In [9]: K.shape Out[9]: (1000,) In [10]: R.shape Out[10]: (1000,) In [11]: np.minimum.reduce([p, K, R]).shape … Read more

[Solved] How do I print lines separately from a txt file in Python 3?

import time file = open(“abc.txt”,”r”) #<– Opening file as read mode data = file.read() #<– Reading data file.close() #<– Closing file data = data.split(“\n”) #<– Splitting by new lines for i in data: #<– Looping through splitted data print(i) #<– Printing line time.sleep(3) #<– Waiting for 3 seconds 1 solved How do I print lines … Read more

[Solved] Pivoting a One-Hot-Encode Dataframe

Maybe I’m missing something but doesn’t this work for you? agg = df.groupby(‘number_of_genres’).agg(‘sum’).T agg[‘totals’] = agg.sum(axis=1) Edit: Solution via pivot_table agg = df.pivot_table(columns=”number_of_genres”, aggfunc=”sum”) agg[‘total’] = agg.sum(axis=1) 2 solved Pivoting a One-Hot-Encode Dataframe

[Solved] Multi-tasking with Multiprocessing or Threading or Asyncio, depending on the Scenario

So off the top of my head you can look at 2 things. 1) Asyncio (be careful this example uses threading and is not thread safe specifically the function asyncio.gather) import asyncio for work in [1,2,3,4,5]: tasks.append(method_to_be_called(work)) results = await asyncio.gather(*tasks) 2) Asyncio + multiprocessing https://github.com/jreese/aiomultiprocess 1 solved Multi-tasking with Multiprocessing or Threading or Asyncio, … Read more

[Solved] How do I find the number of fridays between two dates(including both the dates) [closed]

Number of days between two dates: import datetime start = datetime.datetime.strptime(raw_input(‘Enter date in format yyyy,mm,dd : ‘), ‘%Y,%m,%d’) end = datetime.datetime.strptime(raw_input(‘Enter date in format yyyy,mm,dd:’), ‘%Y,%m,%d’) diff = end-start print diff.days >> 361 Getting number of Fridays: # key 0 would be Monday as the start date is from Monday days = { 0: 0, … Read more

[Solved] How to debug this Python code? [closed]

(IS THE CODE GIVEN BELOW THE RIGHT CODE FOR THE ABOVE QUESTION WILL THIS PYTHON CODE WORK FOR THE ABOVE QUESTION?? ) ANSWARE : no , you can compare your code with my writed code , you have used unnecessary neted loops and lists and your code is not clearly unreadable how can i solve … Read more