Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loop to make it easier
#1
Hi Friends ,
i have some aggregation to provide in xlsx files and i need to use a for loop to make it easier
i have columns in dataframe df.columns = (id ,a,b,c,d,e,f,j,h)
i want to repeat the same process for all columns using count aggregation with id
for example to obtain the dataframe aggregate_A_B the code is :

aggregate_A_B = df[['a','b']].groupby['id'].count # aggregation with id 
aggregate_A_B = pd.dataframe (data= aggregate_A_B)# transform to a dataframe
aggregate_A_B.to_excel(aggregate_A_B.xlsx) # export to xlsx file 
i need to repeat the same to get the combination between all columns and i'm thinking about a loop for to save time
kimdly help
regards .
Reply


Messages In This Thread
For loop to make it easier - by Amirdst - Feb-18-2020, 02:24 AM
RE: For loop to make it easier - by pyzyx3qwerty - Apr-28-2020, 10:18 AM
RE: For loop to make it easier - by Yoriz - Apr-28-2020, 04:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to make for loop display on 1 Line Extra 3 1,468 Jan-12-2022, 09:29 PM
Last Post: Extra
  Looking for discord bot to make loop ping for address ip tinkode 0 1,841 Jul-26-2021, 03:51 PM
Last Post: tinkode
  Easier way to manage dependencies? Tylersuard 2 2,370 Jan-01-2020, 09:19 PM
Last Post: Tylersuard
  making the code easier, list comprehension go127a 2 2,082 May-26-2019, 06:19 PM
Last Post: Gribouillis
  How to make loop go back to the beginning if test evaluaes to True. FWendeburg 1 2,851 Feb-13-2019, 01:26 AM
Last Post: stullis
  How can I do it easier ? Mike Ru 7 4,988 Jul-31-2017, 05:41 PM
Last Post: wavic
  [ tools atom v pycharm ] -- when it comes to easier learning, and making life easier, oneofakindpython 2 3,383 Jun-18-2017, 08:19 AM
Last Post: 3cxmostar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020