Relative Content

Tag Archive for pythondataframe

How can i develop a python code to calculate Development factors ? (used in credit risk management)

So i have a data frame with row labels as months and the columns are amounts in float format, i need to sum and multiply the columns in such a way, in which the numbers of rows when the code takes to calculate the sum changes are according to the user, which means the user should be able to take 12 months values 24 etc. The summation of the columns should be divided by the previous column, so the division should be Current_sum(Column) / Previous_sum(Column). The sum should be in such a way in which the code should exclude the last row of the DataFrame when it sums to 12 or 24 values according to user.

Problem with added dataframe column shift

I tried to apply my newly acquired pandas skills to a typical ANOVA calculation on large dataset with 5, partially nested indices. The corresponding dataframe “dSchema” looks like this:

Find the total time spent in each different location, daily

I want to find the total time in each location, daily. I have dataframe with two columns. One for the locations and one for the arrival time to that location. The next location could be the shame as before because of a sensor reactivation. So i have something like this for example:

How to update fields with previous fields value in polars?

I have this dataframe: import polars as pl dff = pl.DataFrame({‘file’:[‘a’,’a’,’a’,’a’,’b’,’b’], ‘ru’:[‘fe’,’fe’,’ev’,’ev’,’ba’,’br’], ‘rt’:[0,0,1,1,1,0], }) dff With the values: file ru rt “a” “fe” 0 “a” “fe” 0 “a” “ev” 1 “a” “ev” 1 “b” “ba” 1 “b” “br” 0 I’d like to update all ru and rt fields within the same file field, with the […]

Why do similar dataframes showing tow different index types?

I’m trying to create a graph of PnL vs. price from a simulation of a call option. I have to extract data from the results of the simulation. I wanted to combine the extracted data into a single dataframe, but my resulting dataframe does not join them. I found out that the index of the two extract dataframes is different…..would appreciate if someone could explain what’s going on.
In the screenshot below – I see the terminal_price dataframe having an Index type object. The other dataframe of PnL values however is a RangeIndex. I checked…both the df’s have same dimensions and are the same class; i.e. pandas.core.frame.DataFrame. So I’m not sure exactly what’s going on here…..why do I get two different index types? Would appreciate some guidance. I will try to convert the data extracts into pure series and then convert back into a concatenated dataframe….but in the meantime….why is this even happening?

How can I merge multiple financial statements into a single dataframe, only by locations?

I’ve been trying to merge mutliple financial statements, without sacrificing line items, and merging all the items along with the years amnd year’s value to get the a larger statement with this items and years. I’ve tried a few aprproach but I’m very rookie at coding, I export the dataframes (BALANCE SHEETS) for ilustration purposes.https://1drv.ms/f/c/175d836e30c91f0a/Ep80w4-k929ElYJ_NIcFa4sB8Bwm3JgZYTCDz_b0XKx3BQ?e=MXHRuI