python-3.x

Python <function at 0x> output [duplicate]

北战南征 提交于 2021-02-11 06:31:52
问题 This question already has answers here : “Function ________ at 0x01D57aF0” return in python (2 answers) Closed 4 years ago . I wrote a new function and when I execute it, I get an error: <function read_grades at 0x000001F69E0FC8C8> Ok so here is my code: def add(x, y): z = x / y * 100 return z def calc_grade(perc): if perc < 50: return "1" if perc < 60: return "2" if perc < 75: return "3" if perc < 90: return "4" if perc >= 90: return "5" def calc_command(): num1 = input("Input your points: "

Python <function at 0x> output [duplicate]

淺唱寂寞╮ 提交于 2021-02-11 06:31:33
问题 This question already has answers here : “Function ________ at 0x01D57aF0” return in python (2 answers) Closed 4 years ago . I wrote a new function and when I execute it, I get an error: <function read_grades at 0x000001F69E0FC8C8> Ok so here is my code: def add(x, y): z = x / y * 100 return z def calc_grade(perc): if perc < 50: return "1" if perc < 60: return "2" if perc < 75: return "3" if perc < 90: return "4" if perc >= 90: return "5" def calc_command(): num1 = input("Input your points: "

Broadcasting/Vectorizing inner and outer for loops in python/NumPy

允我心安 提交于 2021-02-11 06:30:32
问题 Purpose I have turned a double for loop into a single for loop using vectorization . I would like to now get rid of the last loop . I want to slice an Nx3 array of coordinates and calculate distances between the sliced portion and the remaining portion without using a for loop . Two cases (1) the slice is always 3x3 . (2) the slice is variable i.e., Mx3 where M is always significantly smaller than N Vectorizing the interaction of 1 row of the slice interacting with the remainder is

Dictionary - 'str' object is not callable [closed]

落爺英雄遲暮 提交于 2021-02-11 06:30:17
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Improve this question I am new to Python and trying to create a user interface with options to insert, delete and update data. THe data will be manipulated in a text file. I wanted to accept option from user and call respective function to do the activity. One alternative that I found

dynamically create string from three data frames

半城伤御伤魂 提交于 2021-02-11 06:29:31
问题 Dynamically create string from pandas column I have three data frame like below one is df and another one is anomalies:- d = {'10028': [0], '1058': [25], '20120': [29], '20121': [22],'20122': [0], '20123': [0], '5043': [0], '5046': [0]} df1 = pd.DataFrame(data=d) Basically anomalies in a mirror copy of df just in anomalies the value will be 0 or 1 which indicates anomalies where value is 1 and non-anomaly where value is 0 d = {'10028': [0], '1058': [1], '20120': [1], '20121': [0],'20122': [0]

Count occurance of number from given range

☆樱花仙子☆ 提交于 2021-02-11 06:16:47
问题 My objective is to count the frequency of number in num_lst to the range in num_range. And display the output to a dictionary where key is the range, value is the frequencies of numbers within the range from num_lst. I've seen many posts and most are using numpy or pandas to solve it. However I want to find traditional ways to solve this without using np and pd. Can anyone give me the right direction. num_range = [(0.0, 20.0), (20.0, 40.0), (40.0, 60.0), (60.0, 80.0), (80.0, 100.0)] num_lst =

Count occurance of number from given range

橙三吉。 提交于 2021-02-11 06:16:08
问题 My objective is to count the frequency of number in num_lst to the range in num_range. And display the output to a dictionary where key is the range, value is the frequencies of numbers within the range from num_lst. I've seen many posts and most are using numpy or pandas to solve it. However I want to find traditional ways to solve this without using np and pd. Can anyone give me the right direction. num_range = [(0.0, 20.0), (20.0, 40.0), (40.0, 60.0), (60.0, 80.0), (80.0, 100.0)] num_lst =

how can i call optbinning module get results of all varible binning

六眼飞鱼酱① 提交于 2021-02-11 06:11:59
问题 Now i use optbinning module to binning all logstic regression modeling varible. however optbinning module need to use only one variable ,such as variable = "REGION_POPULATION_RELATIVE" x = df[variable].values y = df.TARGET.values from optbinning import OptimalBinning optb = OptimalBinning(name=variable, dtype="numerical", solver="ls", max_n_prebins=100, min_prebin_size=0.001, time_limit=50) optb.fit(x, y) how can i use loop to get binning result for all variable ? i try to codeing variable

how can i call optbinning module get results of all varible binning

元气小坏坏 提交于 2021-02-11 06:09:57
问题 Now i use optbinning module to binning all logstic regression modeling varible. however optbinning module need to use only one variable ,such as variable = "REGION_POPULATION_RELATIVE" x = df[variable].values y = df.TARGET.values from optbinning import OptimalBinning optb = OptimalBinning(name=variable, dtype="numerical", solver="ls", max_n_prebins=100, min_prebin_size=0.001, time_limit=50) optb.fit(x, y) how can i use loop to get binning result for all variable ? i try to codeing variable

How do I exclude header and footer from an excel file in pandas

血红的双手。 提交于 2021-02-11 06:00:53
问题 df=pd.read_excel(filename) What attributes should I add to exclude header and footer? 回答1: Head over here: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_excel.html you will find pandas.read_excel(io, sheet_name=0, header=0, names=None, index_col=None, usecols=None, squeeze=False, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, keep_default_na=True, verbose=False, parse_dates=False, date_parser