Automate Pivot Tables and Charts with Python | Excel Automation Hacks

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024

Комментарии • 40

  • @ItsJorgePerez
    @ItsJorgePerez 3 года назад +3

    I appreciate your real life use case. Thanks for sharing!

  • @lshankar83
    @lshankar83 4 года назад +3

    Thanks.. The graph is in the image format, which i cannot edit right?

  • @radams7532
    @radams7532 Год назад

    Another great video! You certainly have real life scenarios that I can use. I will certainly subscribe and continue watching. I see this works for columns that have numeric data. What if I wanted to count of each item in a column?

    • @radams7532
      @radams7532 Год назад

      FIgured it out!
      df_pt= pd.pivot_table(df1, index=piv_index, values=cnt_column, columns=piv_data, aggfunc='count')

  • @tonybelair2113
    @tonybelair2113 3 года назад +1

    WOW Thank you !! It s exactely what i m looking for long time. How can i drill to the pivot table data to have the details of the table like in Excel ??

    • @SATSifaction
      @SATSifaction  3 года назад +1

      You can always embed the details in the data frame and use pandas search to drill down

  • @joey5069
    @joey5069 4 года назад

    thanks! this is awesome! I have one question tho. In my graph everything is blue. Can I gave my index input a different color in te graph? so that I can differentiate between the two?

  • @dharmdutt1771
    @dharmdutt1771 11 месяцев назад

    Hi, any guidance how to add data labels to the chart?

    • @dharmdutt1771
      @dharmdutt1771 11 месяцев назад

      @radams7532- any guidance pls

  • @AnirudhGarg1123
    @AnirudhGarg1123 4 года назад +2

    Do we have python libraries for Numbers app in Mac instead of MS Excel?

    • @SATSifaction
      @SATSifaction  4 года назад

      Great question. Not that I know of however it’s always a safe bet to convert all your spreadsheets to csv. Alternatively I’m sure you can write an AppleScript but I haven’t tried it myself. If you do find a library let me know and I’ll be sure to give you a shout out for doing so

  • @sangdao9345
    @sangdao9345 4 года назад +1

    That's amazing. Is there any way we can edit the graph in the exported file, without changing the code? That would be more convenient for business users. For example: i want to see sales by quarter in the pivot, but after that I want to see only number of orders by quarter (I don't want to put sales and orders in the same graph).

    • @radams7532
      @radams7532 Год назад

      I would say just create two graphs and put them next to each other or one on top of the other. Just modify "for k" loop to accommodate another graph?

  • @ahmedmohiuddin8225
    @ahmedmohiuddin8225 3 года назад

    How to change the name of worksheet generated for Pivot table and chart Excel?
    If I am having same name Excel from before the new Pivot table Excel is replacing the previous Excel with same name. Kindly, let me know how to give custom name for the newly generated workbooks

  • @shubhampaul6393
    @shubhampaul6393 3 года назад

    Line no 34: worksheet.insert_image() is throwing error "AttributeError: 'Worksheet' object has no attribute 'insert_image'" Any solution for this?

  • @morganlefay-k4c
    @morganlefay-k4c Год назад

    Just a question, you created a chart using ExcelWriter and Matplotlib with some data. You can create a pivot table using those libraries and the same data? I can't find nothing for pivot tables.

    • @KgRu1eS
      @KgRu1eS 5 месяцев назад

      Yes you can. You can use a library could Openpyxl.

  • @suneelreddy4396
    @suneelreddy4396 5 лет назад +1

    Good Video.
    Sir How can we Automate Power Point.?

    • @SATSifaction
      @SATSifaction  5 лет назад

      Suneel Reddy interesting comment. What part of PowerPoint would you want to automate?

    • @suneelreddy4396
      @suneelreddy4396 5 лет назад +1

      @@SATSifaction let's say by using python (Pandas and Matplotlib) we are created some graphs (.png or .jgp) those graphs we are saved in some folder.
      By using python script we need to place those images in to PPT.
      Sir can you send one test mail to my mail. (Suneelreddy@live.com)

    • @SATSifaction
      @SATSifaction  5 лет назад +3

      Ok let me give that some thought perhaps I can figure it out and post a tutorial in the future

  • @yooalejandro386
    @yooalejandro386 4 года назад

    Could you please share the sampledata.xlsx

  • @stilianstoilov3728
    @stilianstoilov3728 4 года назад

    Thanks for the video. I want to do a similar thing. To read from excel file(first sheet), create a Pivot table and save it to a new sheet.
    This is what i have:
    ###################
    orders = pd.read_excel('/path_to_the_file/filename.xlsx', 0)
    table = pd.pivot_table(orders, index='Component/s', values='Key', columns='Resolution', margins=True ,aggfunc='count')
    ###################
    I'm succesfully creating the pivot table, but can't figure out how to write it in new sheet. Can you advise me something?

    • @SATSifaction
      @SATSifaction  4 года назад +1

      Check out this link I’m sure it will help: xlsxwriter.readthedocs.io/tutorial03.html

    • @stilianstoilov3728
      @stilianstoilov3728 4 года назад +2

      @@SATSifaction I've manage to do it using the following code. 10x anyway :)
      # Writes the pivot table to new sheet called Pivot.
      with pd.ExcelWriter(path='/path_to_the_file/filename.xlsx', engine="openpyxl", mode='a') as writer:
      p_table.to_excel(writer, sheet_name='Pivot')

  • @abhijithati4260
    @abhijithati4260 3 года назад

    In case we're making a video on Python we should share the code ...

    • @SATSifaction
      @SATSifaction  3 года назад

      Most python tutorials have code on github. Feel free to browse my github 👉🏼 github.com/satssehgal

  • @hellofrombd1960
    @hellofrombd1960 4 года назад

    Sir, is it possible by jupytet notebook. If so please make a video. Or if you have already video of this Process by jupyter please share the link in reply

  • @jdparden
    @jdparden 3 года назад

    what if your column name has spaces??

    • @jdparden
      @jdparden 3 года назад

      just put quotes around it... lol nvm

    • @radams7532
      @radams7532 Год назад

      for df in file_dfs:
      df.columns = df.columns.str.replace(' ', '_')

  • @Ashoks1985
    @Ashoks1985 4 года назад

    While run im getting this error "AttributeError: module 'pandas' has no attribute 'Excelfile'" is there anything todo in the code16th line above video

    • @radams7532
      @radams7532 Год назад

      It is case specific... It has to be "ExcelFile" not "Excelfile"

  • @rameshyelle2884
    @rameshyelle2884 4 года назад +2

    Please share code for practice

    • @richardpassett924
      @richardpassett924 4 года назад +2

      Over a third of this video is dedicated to sharing and explaining the code.

  • @Kingcolumbian
    @Kingcolumbian 4 года назад

    you dont know that Excel can automate table in just 1 click only. repeatative data/

  • @NilayMukhopadhyay
    @NilayMukhopadhyay 3 года назад

    You can easily do that with Excel Power Query. 😂😂

    • @KgRu1eS
      @KgRu1eS 5 месяцев назад

      You wouldn't be able to split the files like he did. Also customizing the pivots would have to be done manually.