0

type of data_frame There are 85 something columns and 800+ rows data frame look like this

for eg jan-1 jan-30 feb-1 feb-28 march-1 march-30

party Debit Credit Debit Credit Debit Credit
xyz 0 0 100 200 10 10

What I am trying to do

Credit and debit is for each month for e.g jan1 - jan30 what i want is i want to make new dataframe which will have credit - debit for each month for each party for eg for jan month credit - debit for party xyz and feb month etc

I tried to throw iterrows but was unable to do it

data_set = {
            "Party": [],
            "Month": [],
            "Total": []
        }

Name of dataFrame is new_data_set

  for ind, row in new_data_set.iterrows():
        data_set["Particulars"].append(ind)
        data_set["Month"].append("")
        data_set["Total"].append(row["Debit"] - row["Credit"])

not getting desired output

  • Is there any ability to edit how the dataframe is created in the first place? Having the data stored in rows, while the columns have repeated names, seems like it adds a lot of complexity – G. Anderson Aug 19 '21 at 20:53
  • if you share a sample of the data just like it recommends doing so in [here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) there is a possibility that someone can help you. – alparslan mimaroğlu Aug 19 '21 at 21:14

0 Answers0