Skip to content

Tag: python

Linear regression plot on log scale in Python

I want to do linear regression to the data given by x and y. Everything seems to be fine when I use a linear plot, but when I want to plot it on a log scale the line does not look straight. I think I should divide the interval into finer grids rather than only six points. But I couldn’t

Items not being appended properly

I was working on the following code which will take input the scrap which has a few phrases as: Now I want the phrases in scrap which have used the words in prog_list to be appended to TRUE_PROG : I wrote a simple code having loops in it, but it produces an output that I didn’t expect: PROGRAM CODE: If

Usage of sorted with ord() and lambda in python

I was doing an exercise on Hackerrank, and in the discussion I stumbled upon a very nice one line solution to solve the following question: S is an alphanumeric string, and you have to sort it using the following rules: All sorted lowercase letters are ahead of uppercase letters. All sorted uppercase letters …

Python regular expression how to deal with multiple back slash

I’m dealing with text data and having problem erasing multiple back slashes. I found out that using .sub works quite well. So I coded as below to erase back slash+r n t f v However, the code above can’t deal with the string below. So coded as this: But it’s showing result like this.. I don’t know why this hap…