Skip to content

Tag: python

PySpark create a json string by combining columns

I have a dataframe. I would like to perform a transformation that combines a set of columns and stuff into a json string. The columns to be combined is known ahead of time. The output should look like something below. Is there any sugggested method to achieve this? Appreciate any help on this. Answer You can …

Add pivot table in excel with python

I am trying to add a pivot table in excel using python script with pandas but not able to do so. I won’t to count number of missed and met entries for each priority. Excel script: Excel data: Priority SLA p1 Met p2 Missed p3 Missed p2 Missed p3 Missed desired output: Priority Met Missed p1 1 0 p2 1

The method doesn’t want to enter in for loo

What’s the problem with this damn loop? I don’t understand why the method doesn’t acces the loop. I tried to make videos a list because cursor type can’t be parsed. If I’m running this for loop alone, without the if statement above, it works. Answer videos is an iterable, and you…

how to ignore null values in DataFrame when comparing columns

I am new to Pandas and learning. I am reading excel to DataFrame and comparing columns and highlight the column that’s not same. For example if Column A is not same as Column B then highlight the Column B. However I have some null values in Column A and Column B. When I execute the code, I don’t w…

Why can’t I write to a text file? Python 3.10

I tried ‘r+’ and ‘w+’ but couldn’t write. I’m not getting any errors. what could be wrong? I had changed the position WITH but nothing changed. I want to write the STRING of the ARTICLE TITLE in a text file. I can write to csv. The error I am seeing now is this. UnicodeEnco…