Skip to content

Tag: pandas

Python – Unable to export sql result to Excel

I want to export sql query result to excel file using Python. I queried the DB and able to retrieve the result set.Currently what im facing is like.Not able write the query result to Excel, Here is my Code, When im running this code,its skipping to the except block.Is there anyway to figure out the issue? &#8…

Using groupby on already grouped data in Pandas

I would like to achieve the result below in Python using Pandas. I tried groupby and sum on the id and Group columns using the below: I got the first two columns, but I’m not sure how to get the third column (Overall_Total). How can I do it? Initial data (before grouping) id Group Time 1 a 2 1 a

Get cumulative sum in pandas

Context Datetime Campaign_name Status Open_time 2022-03-15 00:00 Funny_campaign Open 2022-03-15 01:00 Funny_campaign Continue 2022-03-15 02:00 Funny_campaign Continue 2022-03-15 03:00 Funny_campaign Continue 2022-03-15 04:00 Funny_campaign Close 2022-03-15 08:00 Funny_campaign Open 2022-03-15 09:00 Funny_camp…

How to search a dataframe value based on another dataframe value?

I have two DFs: Now I would like to compare the two dfs and put a column ‘True’ in df2 when the color column of df2 is residing in df1. desired output: I came up with the following: However got the following error: And tried the following ValueError: Length of values (5) does not match length of i…