Skip to content

assign key as list index+1 to list of tuples [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have a list of tuples and I want to convert them to dictionary but the key should be tuple…

TypeError during resampling

I am trying to apply resampling for my dataset which has unbalanced classes. What I have done is the following: Unfortunately, I am having some problems at this step: X = pd.concat([X_train, y_train], axis=1), i.e. You can think of Text column as I hope you can help me to handle with it. Answer You have to co…

LightGBM does not accept the dtypes of my data

I’m trying to use LGBMClassifier and for some reason, he does not accept the types of my data (all features are not accepted, I tested it). When we look at my data we can clearly see that all dtypes are either category, float or int (pd.DataFrame.info()) When I eventually try to train my LGBMClassifier …

Confused on Index Slicing in python

I am slicing my hour column and when I use slice(1, 3) and slice(0, 3) I get the same results. What am i missing? See in the image below. Answer There is a space at the beginning of dataset[“hour”]. So slice(0, 3) is ” 02″ while slice(1, 3) is “02”. This was answered by @Ba…

how to fix TypeError: ‘str’ object is not callable in Python

Im gettng this error: SyntaxWarning: ‘str’ object is not callable; perhaps you missed a comma? For code: Answer The concatenation of strings works differently. if you use Python 3.6+ or for earlier versions. You can also do as follows: which makes your code more concise and pythonic.

Python To-Do List List/Loops

Been having some trouble with trying to make this to do list code. I’m trying to Write a program that will prompt the user to enter an item for their to-do list. Each item is then added to a list. When the user enters no input, the program will display the to-do list in two columns. The thing is though