Skip to content

Tag: python

Create pandas dataframe from multiple sources

I need to create a pandas dataframe using information from two different sources. For example, The first 3 columns in the dataframe I want should contain c1, c2, c3, and the rest of the columns come from the key of the returnedDict. The number of keys in the returnedDict is 100. How can I initialize such Data…

Map with bubbles with radius on basis of counting

I have this easy script for creating bubbles on map, but I would like bubbles with radius on basis of intensity. I put an image with lat, lon and count. In finaly I put the map result, but there aren’t bubbles. Where I am wrong? dataset Answer The reason for the display seems to be that the default valu…

How to replace ffill() method with custom function in pandas

here is my sample df: If I would like to replace the NaN values and ffill the last number (70.2 – in this case), I would simply apply: However, what if I would like to apply a custom function instead of ffill() method: For instance, I need the NaN values of y column to be replaced with “2 * x^2&#8…

How to extract value from tuple of tuples

I have list of this sort. It is the order list of a person: How do I extract the string and the float value separately? I need to calculate the total order cost based on the given fruit prices: This is what I have tried: This yields wrong answer. What am I doing wrong? How can I fix this? Thanks!

Error You have an error in your SQL syntax

When I do the following request I get the message : (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘>= DATEADD(MONTH, -3, GETDATE())’ at line 1”). The request is : This request works when …

How to split a string with space into two lines in python

I am trying to split github.com/pmezard/go-difflib v1.0.0 into name and version I tried like this but it only split into 2. output i am getting is [{‘name’: ‘pmezard’, ‘version’: ‘v1.0.0n’}] Expected output [{‘name’: ‘go-difflib’, ‘…