Categories
Mastering Development

SkFuzzy Giving “ValueError: Unexpected input: quality”

CODE SET BELOW WRITTEN IN PYTHON USING SKFUZZY FROM SCI-KIT LEARN: import skfuzzy as fuzz import numpy as np from skfuzzy import control as ctrl import matplotlib.pyplot as plt # New Antecedent/Consequent objects hold universe variables and membership # functions quality = ctrl.Antecedent(np.arange(0, 11, 1),’quality’) service = ctrl.Antecedent(np.arange(0, 11, 1), ‘service’) tip = ctrl.Consequent(np.arange(0, 26, […]

Categories
Mastering Development

indexing rows and columns in numpy

a = np.array(list(range(16).reshape((4,4)) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) Say I want the middle square. It’d seem reasonable to do this: a[[1,2],[1,2]] but I get this: array([5, 10]) This works, but seems inelegant: a[[1,2],:][:,[1,2]] array([[5, 6], [9, 10]]) So my questions are: […]

Categories
Mastering Development

Rewriting a loop with Rccp

I am a novice Rcpp user. I want to fasten my for loop which uses several entities from r environment, and updates two vectors through iterations. The problem is that this is my first time facing c or c++ so I do not understand how to write rcpp with inline packages. Here is the reproducible […]

Categories
Mastering Development

How to convert multidimensional Arraylist to single Arraylist in Java?

[[4, 17, 28, 38, 43, 58, 69, 77, 83], [4, 12, 24, 35, 48, 55, 62, 73, 87], [11, 15, 22, 36, 46, 60, 67, 80, 84]] (which is Arraylist<Arraylist>) how to convert that to this: [4, 17, 28, 38, 43, 58, 69, 77, 83, 4, 12, 24, 35, 48, 55, 62, 73, 87, 11, […]

Categories
Mastering Development

Syntax Error: ‘return’ outside function: my indentations seem to be correct

So first of all im writing a program that will total up all of the values in a list / array and heres what i got so far def go( ann ): total = 0 for i in range(0,len(ann)): total = total+ann[i] return total print ( go( [-99,1,2,3,4,5,6,7,8,9,10,12345] ) ) print ( go( [10,9,8,7,6,5,4,3,2,1,-99] ) […]

Categories
Mastering Development

Hangman game input user word to the game Tkinter

I’m currently working on a Hangman game in python with tkinter. My code is working and now I would like to improve it. My current game is choosing a random word from a list. But I would like to change that so in the start menu the player can choose the word. I’ve tried to […]

Categories
Mastering Development

Get all row values from single column

This code is working and retrieving the exact data i need. I just need to output all the row values into a single value; HERE IS THE bit of CODE dfs = pd.read_html(str(tables)) df = dfs[0].iloc[[1,3,5,7,9,11,13,15,17,19],[1]] s = df[‘score’].str.split(‘-‘,expand=True).astype(int) df[‘team_win’] = np.where(s[0] == s[1], 0,s.idxmax(1) + 1) df = df[‘team_win’].drop([9, 11]) HERE IS THE OUTPUT […]

Categories
Mastering Development

Getting First Element in Nested List in Python

Okay so let’s say I have a list similar to this: list = [‘1’, ‘a’, 11, ‘aa’], [‘2’, ‘b’, 22, ‘bb’] I only want the string ‘1’ to print. If I use: for sublist in list: print(sublist[0]) I get ‘1’ and ‘2’, but I only want ‘1’ to display. Any suggestions?

Categories
Mastering Development

How to implement vlookup style cross referencing with pandas

Given the Following DataFrames jg Job Group 1 116.0 2 116.0 3 116.0 4 116.0 5 116.0 6 116.0 7 124.0 8 124.0 9 74.0 10 74.0 11 74.0 12 126.0 13 126.0 ul UpperGroup LowerGroup Time 116 116 5 116 124 15 116 74 15 116 126 15 124 116 15 124 124 5 […]

Categories
Mastering Development

Show tooltip on plotly based on x-axis

I have an interactive chart which shows a predicted value and an upper and lower confidence interval. I have the chart looking exactly as I want it to, however the tooltip behavior is not what is desired. Is there anyway to show tooltip information based on where on the x-axis the cursor is, rather than […]