I tried to takeout decimal values based on value present before decimal point .I have data frame like below, Expected output, How can i achieve this using pands,… Answer If data is a string: if it is a float: output:
Tag: python
How can I remove a part of the JSON, and can someone explain how It works?
So I’m new to the JSON files, I was trying to make that my python program deletes a JSON “line” when something happens, I got the code that write in the JSON but I don’t know how it works, I would appreciate that someone explains how it works: And the JSON looks like this: How could I …
why returning None in functions python?
first image I was having problem when I run this code I raise exception in function then why none is printing sec image And in this case none is not printing.. pls help Answer when a python function does not have a return statement it automatically return None. In the first image, the print(numcheck(5)) pass …
Check for string in list items using list as reference
I want to replace items in a list based on another list as reference. Take this example lists stored inside a dictionary: Then, I have this list as reference: My result should look like this: I want to check if any of the list items inside “wishlist” is inside one of the values of the dict1. I tri…
Fit/transform separate sklearn transformers to partitions of single column
Use case: I have time series data for multiple assets (eg. AAPL, MSFT) and multiple features (eg. MACD, Volatility etc). I am building a ML model to make classification predictions on a subset of this data. Problem: For each asset & feature – I want to fit and apply a transformation. For example: fo…
How to get a value of list from for loop in python?
I have list : Here I need output as the list consists of 5,6,7 from the list, that is [5,6,7] So for that I tried like below, when I print s inside the for loop, I am getting the output but if I print outside the loop the output is just 7. Please help me out Answer You can do
Merge two dataframes with subheaders
So I have my first dataframe that has countries as headers and infected and death values as subheaders, then I have my second dataframe, I want to merge the dataframes so that the indicator columns become subheaders of the countries column like in df with the infected and dead subheaders. What I want to produ…
How to only get the shortest path with networkx (shortest_path)
first of all I am really new to python in genereal and espcially to networkx. I got a question regarding the networkx shortest_path(G,source,target) function. For a series of found positions (let´s call them x), I would like to find the shortest path to another series of found positions (let´s call them y). I…
Heights of dropdown and button are different. Dash Plotly python
I am trying to make a dashboard with dash in python and I am trying to align 2 dropdowns and a button horizontally this is the html.Div that I am working with Is there any way to make the height of the do something button the same as that of the dropdown even when the window is resizing. Or Is
Dataframe, sum positive and negative value on specific date interval
here’s the context : I have 2 dataframes, one from a database that generate a one month series, and the second one is a download from another database, but on one year. I have make a plot where df1 and df2 are subtracted, creating a filled curve between, and I force the plot on just one month, so visual…