Skip to content

problem with csv file to open it with csv.reader

I have the following code: But it errors: When I change ‘rb’ to ‘rt’: It says: And when I delete .astype(‘float’), the result is (769, 9) but the expected result is (768, 9). It counts the header as data. Can you tell me why? Answer Before you do following: try which should…

Print linear constraints of CPLEX LP on Python

I need to print all my linear constraints to verify the correctness of what I wrote but not knowing the CPLEX library for Python well I would not know how to do it. That’s my part of LP: I want to print out these 22 linear constraints. I’m working with CPLEX 12.9 on Python 3.7.9 Answer This will w…

Novice Python User having issues with simple functions

I am trying to make a simple python program that takes 3 inputs Number of stocks I will Buy Price per share of stock when bought Price per share of stock when sold. In this exercise, there is a 15% commission fee both when buying, and selling the stock. The 4 outputs I am attempting to receive are: Price of

Pandas union with parent ids in the same dataframe

I have a pandas dataframe that looks like this: I want to return the folder structure for each line in a separate colunm, for example line 1: A is the root there is no parent all ids are 0 = A line 2: B is under A, id = 1, so the path is A/B line 3: C is under