How to Generate an Analytics Report (pdf) in Python!

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 2024
  • The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: skl.sh/keithgalli10201
    In this video we see how we can take visualizations that we plot in python libraries like Matplotlib & Plotly and package them into a nice looking analytics report using the fpdf library.
    Source code: github.com/keithgalli/generat...
    Data: github.com/CSSEGISandData/COV...
    PyFPDF Docs: pyfpdf.readthedocs.io/en/latest/
    Helpful blog post mentioned: towardsdatascience.com/covid-...
    Thank you to Skillshare for sponsoring this video!
    -------------------------
    Follow me on social media!
    Instagram | / keithgalli
    Twitter | / keithgalli
    -------------------------
    Video Timeline!
    0:00 - What we will be doing in this video
    1:30 - Check out Skillshare! (sponsored)
    3:00 - Source code & Setup
    6:37 - Python FPDF library basics
    9:42 - Choosing our paper format (A4, Letter, etc)
    11:54 - Adding and resizing images in our PDF!
    18:52 - Helper method (which states & countries can we plot?)
    21:48 - Continuing to build out our report (exploring source code)
    27:17 - Adding additional pages to the report
    29:09 - Adding a title to our report
    32:37 - Adding a professional letterhead to report
    35:00 - Plotting geographic maps with covid-19 data (plotly)
    40:02 - Using datetime library to automatically grab & format yesterday’s date
    43:46 - Finalizing our report
    46:41 - Where are the colors set?
    48:11 - Final thoughts
    -------------------------
    If you are curious to learn how I make my tutorials, check out this video: • How to Make a High Qua...
    Practice your Python Pandas data science skills with problems on StrataScratch!
    stratascratch.com/?via=keith
    Join the Python Army to get access to perks!
    TH-cam - / @keithgalli
    Patreon - / keithgalli
    *I use affiliate links on the products that I recommend. I may earn a purchase commission or a referral bonus from the usage of these links.

ความคิดเห็น • 187

  • @KeithGalli
    @KeithGalli  3 ปีที่แล้ว +38

    Hope you all enjoyed this video! If you have any questions, let me know here in the comments :)
    Also for a bunch of great classes be sure to check out Skillshare! The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: skl.sh/keithgalli10201

    • @metameles5846
      @metameles5846 3 ปีที่แล้ว +1

      Thanks a lot for this great tutorial. A bonus would have to add a crosstable data for example.

    • @nikhilprem7998
      @nikhilprem7998 3 ปีที่แล้ว

      th-cam.com/video/PZgQkJSAP2g/w-d-xo.html
      I am stuck in the imaginary number can you solve it?

    • @JaveGeddes
      @JaveGeddes 3 ปีที่แล้ว +1

      I was hoping to find a way to access BeautifulSoup results in html

    • @utkarshaattarde5272
      @utkarshaattarde5272 3 ปีที่แล้ว

      It's super helpful. I have a question - I'm generating a report having header, footer and in body - a table with bar graph. The problem is table continues to 2nd page and overwrite with the header(starts from top ). Please help me with this. You can answer this question on Stack overflow website :- stackoverflow.com/questions/65987187/page-continuation-below-header-in-fpdf
      Thanks in advance

    • @utkarshaattarde5272
      @utkarshaattarde5272 3 ปีที่แล้ว +1

      Please make more videos with fpdf lib

  • @larflores1
    @larflores1 3 ปีที่แล้ว +3

    This is great! Thanks for all the hard work and effort you put into these tutorials. It really comes through how thoughtful everything is on video. Loved it!

  • @tyswenson7542
    @tyswenson7542 3 ปีที่แล้ว +6

    Dude, you read my mind with this video... it’s scary how much I needed this.

  • @amirabdoll
    @amirabdoll 3 ปีที่แล้ว +2

    Just letting you know that you are a champion and I have so much respect and love for you. I am following your post and immensely enjoying them. Keep the great work up.

  • @davidnguyen7160
    @davidnguyen7160 3 ปีที่แล้ว +2

    I have so many projects lined up but keep getting caught up with your projects. Keep up the great work!

  • @mapa5000
    @mapa5000 3 ปีที่แล้ว +1

    I like the way you look for information and handle issues during your video. Excellent job.!!!

  • @chrislee7704
    @chrislee7704 3 ปีที่แล้ว

    Dude thank you!! I'd been searching for a way to generate slick report with python for some time and this has everything I need. Your video also explains the process and features far better than articles I have found.

  • @kbstar12
    @kbstar12 3 ปีที่แล้ว +1

    Thanks Keith! I was able to implement this into my own work this week. Good stuff keep it coming!

  • @kewalmishra7870
    @kewalmishra7870 3 ปีที่แล้ว +3

    Really grateful for ALL the content that you are putting up in this field. You have no idea how much these videos are helping me. THANKS A LOT!

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว

      you're very welcome!!

  • @anthonycamarillo5806
    @anthonycamarillo5806 3 ปีที่แล้ว +3

    Thank you TH-cam algorithm for putting this on my home page when I was getting ready to do intense searching on reporting!
    Also quick suggestion: instead of having to download the libraries each time maybe you can export a virtual environment to YAML file so people will automatically have the environment and all of the dependencies

  • @ritwaj6791
    @ritwaj6791 3 ปีที่แล้ว +2

    Damn finally someone came up with us, I was wondering in these times how did non-technical people understand the visualizations looking at code and also that's also not much appealing showcasing to this kind of people in a presentation meeting.

  • @raulsiqueirayt
    @raulsiqueirayt 3 ปีที่แล้ว +3

    I've been looking for this video a long time, thanks for that, best content ever!

  • @duonghue8388
    @duonghue8388 3 ปีที่แล้ว +2

    Thank you for your work. It's super helpful. Hope to see more of this

  • @mrmuranga
    @mrmuranga 3 ปีที่แล้ว +1

    Amazing....thanks. Jumping right to my first pdf plots from tomorrow..greatstuff !

  • @johnwig285
    @johnwig285 3 ปีที่แล้ว +7

    Wtf i didnt know that was possible. This channel is beyond awesome!

  • @bidhanbhattarai8863
    @bidhanbhattarai8863 3 ปีที่แล้ว +31

    You come up with the most interesting tutorials Keith.

  • @nickt423
    @nickt423 3 ปีที่แล้ว

    Keith, thanks for making these videos. They have really helped me!

  • @GnosisArizona
    @GnosisArizona 3 ปีที่แล้ว

    Keith - thanks for this video. It just arrived exactly when I needed it! Big thanks!

  • @matiastorres392
    @matiastorres392 3 ปีที่แล้ว +1

    Amazing that you Start to show us some of cloud service!! Thats its a must on this days!!! Thanks a lot

  • @Evan_242
    @Evan_242 3 ปีที่แล้ว +1

    Very very useful, I just get a job in Data Science and I'm sure this kind of report will be very handy :) Thanks Keith

  • @rodrigoolanda9176
    @rodrigoolanda9176 3 ปีที่แล้ว

    Dude, you're the best! Thanks for sharing your knowledge!

  • @Oceansteve
    @Oceansteve 2 ปีที่แล้ว

    I watched this today last year and was only starting to learn Python for Data Science. Now I am using it for paid work. TY!

  • @oenriqueg
    @oenriqueg 3 ปีที่แล้ว

    Booom! 🤯🤯🤯🤯
    Thank you very much Keith!!
    I have a lot of things to learn and practice, you are amazing. 🙌🙌🙌🙌🙌🙌

  • @itbeat7899
    @itbeat7899 3 ปีที่แล้ว

    You are awesome! I love you are going through each part of the script

  • @DodaGarcia
    @DodaGarcia ปีที่แล้ว +1

    Thank you for this overview! I am especially impressed by the map plotting functionality, will definitely look into that.
    As someone coming from web dev, thought I'd suggest that it might be easier to, instead of trying to wrangle the PDF layout in the code, generate the report in HTML with the help of a utility CSS library such as Tailwind and then running a separate step to convert that into PDF. That would make it easier to generate a standard layout, and as a bonus would also give you the option to make the HTML version available.

  • @hectormotsepe1581
    @hectormotsepe1581 3 ปีที่แล้ว +7

    Keith Galli.
    You are the best bro
    Much love from South Africa

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว

      Appreciate the support! 🙌

  • @cash80flow
    @cash80flow 3 ปีที่แล้ว

    I am always looking forward to your tutorials. Another great one👍👍

  • @JasonMinhas
    @JasonMinhas 3 ปีที่แล้ว +5

    Hey, Keith awesome tutorial! At 42:23 to remove leading "0" you can do "%#m/%#d/%y" instead. The "#" will remove leading "0"

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว +4

      Great suggestion! So I was going to do this, but I believe that date format is Windows specific. On Linux & MacOS the "#" needs to be a "-", so ultimately I decided to go with a solution I was sure would work on all platforms :).

  • @abhishekgautam478
    @abhishekgautam478 3 ปีที่แล้ว

    man your all videos are awesome. thank you.

  • @e-normous
    @e-normous ปีที่แล้ว

    Thanks a lot for this very helpful tutorial. Keep up the good work!

  • @faizalimuhammadzoda4731
    @faizalimuhammadzoda4731 3 ปีที่แล้ว +1

    Very useful tutorial. Thanks. And greetings from Central Asia.

  • @amanpatyal2187
    @amanpatyal2187 3 ปีที่แล้ว

    Waiting for the second one....
    . Veeeerrry informative...

  • @patrickdamour1728
    @patrickdamour1728 3 ปีที่แล้ว

    ❤️ content is constantly improving!

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว

      Thanks buddy ❤️

  • @yitongsun6702
    @yitongsun6702 2 ปีที่แล้ว

    Thank you, it's really helpful.

  • @TanayaAmar
    @TanayaAmar 3 ปีที่แล้ว

    Love the topic! Thanks so much!! 🤩 And the hairstyle looks great to me - not sure why some folks have a problem lol

  • @gopichand5717
    @gopichand5717 3 ปีที่แล้ว

    Really enjoyed your video
    Thanks for sharing 🙂

  • @alpheim4129
    @alpheim4129 ปีที่แล้ว

    Thank you so much. With your help I have automated reports on my website❤️

    • @KeithGalli
      @KeithGalli  ปีที่แล้ว

      Awesome! You are very welcome

  • @xavierfournat8264
    @xavierfournat8264 3 ปีที่แล้ว +1

    Hi Keith,
    This were the best 49:14 minutes I spent this week...
    ...OK, maybe the second best 49:14, right after the time spent yesterday building play dough dinosaurs with my 2 y.o. son after a 1 week business trip. But you were really close from 1st place, I promised :)
    More seriously, absolutly stunning tutorial! Highly valuable and extremly clearly explained.
    Thanks for that !

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว +1

      This comment put a big smile on my face! I appreciate the kind words. I know I could never compare to building play dough dinosaurs with your son, but I feel honored to even come close :)

  • @brentsimpson3791
    @brentsimpson3791 3 หลายเดือนก่อน

    Awesome video! Thanks

  • @TheMISBlog
    @TheMISBlog 3 ปีที่แล้ว

    Great Video Keith, keep up the good work

  • @AbhishekSharma-hy4nl
    @AbhishekSharma-hy4nl 3 ปีที่แล้ว +3

    I love ur videos bro... because of u I'm able to qualify an data analyst exam also gave some interviews didn't get any hope get in future but anyway thanks alot..❤️❤️ love from India and also make some videos on azure and aws..

  • @williamfarrell3822
    @williamfarrell3822 3 ปีที่แล้ว

    Great job, Keith

  • @web3global
    @web3global 3 ปีที่แล้ว

    Great Efforts Brother !!!
    Keep the work up!

  • @NoahElRhandour
    @NoahElRhandour 3 ปีที่แล้ว +2

    I'm learning python and your tutorials are among the best I've ever seen. thank you sooooo much and greetings from Germany x)

  • @hosseinramezani1428
    @hosseinramezani1428 3 ปีที่แล้ว

    Thank you for your work

  • @thyagovieira6283
    @thyagovieira6283 2 ปีที่แล้ว

    Thanks Keith!

  • @Oceansteve
    @Oceansteve 3 ปีที่แล้ว +1

    Top class content! faultless tutorials..

  • @money_wins_controls
    @money_wins_controls 3 ปีที่แล้ว +2

    You are my hero
    Not all heroes wear caps!

  • @mprencipe
    @mprencipe 2 ปีที่แล้ว

    It would be very nice to have a tutorial on pythontex, too! There are no decent tutorials of this subject and, since your are very skilled in teaching, you would make the difference!

  • @wewjoj
    @wewjoj 3 ปีที่แล้ว

    This video is awesome!

  • @hannukoistinen5329
    @hannukoistinen5329 2 ปีที่แล้ว

    Some statistic courses may should be taken!! Nice keyboard working anyway:)!!

  • @SHABAREESH99
    @SHABAREESH99 3 ปีที่แล้ว

    Thanks you helped me so much in python

  • @Magnus.Ek.1
    @Magnus.Ek.1 3 ปีที่แล้ว

    I use Ananconda and set-up an environment that I named ´covidMap´. In that env with python3.8 I installed all the dependencies. I got the report to run instantly. Next move is to see if I can get it to work with an European map. Thanks for the inspiration!

  • @foxwelly
    @foxwelly 3 ปีที่แล้ว

    I love you Keith!!! Your tutorials are the bees knees!!

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว +1

      thanks broski!!

  • @kacperm2909
    @kacperm2909 5 หลายเดือนก่อน

    Very useful for learning python ;) ThX

  • @kanefoster8780
    @kanefoster8780 3 ปีที่แล้ว +9

    This is absurd! I was quite literally about to search on TH-cam how to design and analytic report in Python. Great minds ey.

    • @ayencoscolfield3312
      @ayencoscolfield3312 3 ปีที่แล้ว

      Wow Great minds! meaning you like it , why is it absurd then , i dont get

    • @kanefoster8780
      @kanefoster8780 3 ปีที่แล้ว

      @@ayencoscolfield3312 Haha I meant it was an absurd coincidence such a video would be uploaded just as I started looking for it, and we were two great minds for thinking of the same idea at the same time

    • @ayencoscolfield3312
      @ayencoscolfield3312 3 ปีที่แล้ว

      @@kanefoster8780 ok i understand now, cheers

  • @drikarts4816
    @drikarts4816 2 ปีที่แล้ว

    Thank you!

  • @Gamma3
    @Gamma3 3 ปีที่แล้ว +1

    Thanks! This is the best channel

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว +1

      appreciate the support 🙌

  • @starlabs7775
    @starlabs7775 3 ปีที่แล้ว

    nice tutorial bro!

  • @yashkaran1
    @yashkaran1 4 หลายเดือนก่อน

    Thanks man!!!!

  • @Trazynn
    @Trazynn 3 ปีที่แล้ว

    You deserve better than Skillshare man.

  • @rezashams7434
    @rezashams7434 3 ปีที่แล้ว

    Attractive as expected 👍

  • @SoutheastSam3
    @SoutheastSam3 3 ปีที่แล้ว

    I needed this. Don't want to scroll through a Jupyter notebook when showing analysis at work.

  • @devjesusc
    @devjesusc 2 ปีที่แล้ว

    Awesome!!

  • @barikam2m891
    @barikam2m891 3 หลายเดือนก่อน

    You are the best thank you.

  • @hansomary3827
    @hansomary3827 3 ปีที่แล้ว

    Great, good job

  • @allanmarzuki5534
    @allanmarzuki5534 3 ปีที่แล้ว

    Awesome tutorial Keith! How about LaTeX tutorial for the next video?

  • @user-nl6vf1cg2s
    @user-nl6vf1cg2s 3 ปีที่แล้ว

    thank you so much. :)

  • @easy_coding0
    @easy_coding0 3 ปีที่แล้ว

    that is Mr i liked the way you rxplain things

  • @ajdevz1067
    @ajdevz1067 3 ปีที่แล้ว

    Thanks for this python tutorials

  • @hansmachtdampf
    @hansmachtdampf 2 ปีที่แล้ว

    Hi Keith,
    Thanks for your videos - they are really great.
    One question that I have - I have done my analysis in Jupyter Notebooks and can render them via voila.
    I use some styling on the tables colors etc.
    Now I want to generate a pdf report out of it.
    Any hint? Especially on the step from Jupyter to pdf.
    Thanks a lot and keep up the great works !

  • @user-he5mq3fv1d
    @user-he5mq3fv1d 3 ปีที่แล้ว

    thank you keith
    (from morocco)

  • @nyasingajeff1789
    @nyasingajeff1789 3 ปีที่แล้ว

    I see You Got a new haircut, But as Usual Fresh Content.. Awesome Content

  • @vitoroliveiradesouza4214
    @vitoroliveiradesouza4214 ปีที่แล้ว

    Hi Keith! Awesome Tutorial, thanks for sharing it!
    Just one quick question: Did you realize you were clicking the rotate button instead of the update one at 26:30?

  • @swm7f137
    @swm7f137 2 ปีที่แล้ว

    can we use this package in dash plotly please advice
    and thank you so much for your hard work

  • @israeldeandrade4022
    @israeldeandrade4022 ปีที่แล้ว

    thank you

  • @alimehrhosseini2230
    @alimehrhosseini2230 3 ปีที่แล้ว

    Tnx Keith

  • @joaopedrodanhoni5681
    @joaopedrodanhoni5681 3 ปีที่แล้ว

    Fkn A bro. Amazing.

  • @ritwaj6791
    @ritwaj6791 3 ปีที่แล้ว +2

    Also could you please make a git and GitHub full tutorial video explaining things like settings to opt while installing, cloning, and uploading the first project. T

  • @spyxfam
    @spyxfam 3 ปีที่แล้ว

    Love your vid :) Is it also possible to add other font family like Verdana?

  • @afgaco
    @afgaco 2 ปีที่แล้ว

    GRACIAS!

  • @Magmatic91
    @Magmatic91 3 ปีที่แล้ว

    Please make a video about a real world project in Data Analytics like the one you did on Sales Analytics. Thanks.

  • @marcelocampos665
    @marcelocampos665 ปีที่แล้ว

    Nice!

  • @ericbi8338
    @ericbi8338 3 ปีที่แล้ว

    Keith, you are so cool!

  • @dr.girthmuffin8584
    @dr.girthmuffin8584 3 ปีที่แล้ว +1

    Weepee! what a great vid u have! just the right size for me! I hate when they try to cram too much into short vid. OUCH!
    Anyways! I do wonder though... should I use PDF for my wedding invitations or is more for legal documents?
    keep up great fun!
    -Doc

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว +1

      Good to hear from you again Dr. Girth Muffin! It's been a while. Yeah I definitely recommend this method for wedding invitations. You can even go as far as using an API to automatically send them, wouldn't that be neat! xoxo keith

  • @GhizlaneBOUSKRI
    @GhizlaneBOUSKRI 3 ปีที่แล้ว

    Finally 🙏🏻

  • @GOTTT
    @GOTTT ปีที่แล้ว

    Hey Keith,
    Amazing video! Really well explained and helped me out a lot here.
    My problem is that the pdf generation is taking forever!
    Even just 1 image. Do you know why this could be?

  • @ivannordnesdahlberg6368
    @ivannordnesdahlberg6368 3 ปีที่แล้ว

    Thanx for another great tutorial. Can you also show an example where you include some nice tables in the PDF report?

    • @KeithGalli
      @KeithGalli  3 ปีที่แล้ว +1

      Glad you enjoyed the video! I might create some examples with tables at some point, but until I do that this answer on stack overflow might be helpful: stackoverflow.com/a/39358752

  • @pedrobarros9444
    @pedrobarros9444 3 ปีที่แล้ว

    thanks keith uber!

  • @Voltaire321
    @Voltaire321 3 ปีที่แล้ว

    pipenv is really nice for handling dependencies so you don't have to manually install modules

  • @Hibernatus50
    @Hibernatus50 3 ปีที่แล้ว

    Hello, thanks for the video, super informative! However, I'm having an issue with the create_usa_figure function. It throws me an error : "write_image() got an unexpected keyword argument "engine" " . For the life of me, I can't figure out how to solve that (tried removing it, tries reinstalling plotly, installing kaleido, ...) nothing works and can't find help on StackOverFlow.
    Do you have an idea?

  • @HardCloserTV
    @HardCloserTV 3 ปีที่แล้ว +1

    Hello Keith ! I'm having problems importing the fpdf library
    ImportError: cannot import name 'FPDF' from partially initialized module 'fpdf' (most likely due to a circular import) help please 😪

  • @martinkroll1613
    @martinkroll1613 3 ปีที่แล้ว

    Hi, thanks for a great video!
    I was trying to follow your tutorial with data from db of my Django project and faced the following problem:
    If I don't save charts and just add them to memory stream (buf_chart = io.BytesIO() plt.savefig(buf_chart, dpi=200) I can't use pdf.image( ) method as it expects image path as first argument and not binary data.
    Any suggestions how can I add images to pdf from memory without saving them?

  • @ethanl1402
    @ethanl1402 2 ปีที่แล้ว

    Hi Keith, just wondering how to make this python report in an interactive version with clickable graph showing like a html format and sharing to others who is able to open and click. Cheers

  • @monkyspnk777
    @monkyspnk777 3 ปีที่แล้ว

    This is a great tutorial. Can you do one that creates a core program that starts every time the computer starts and I can have it run other Scripts like this one?

  • @python360
    @python360 3 ปีที่แล้ว

    Nice video, no need to try Skillshare with people like you making vids on YT!
    I have just been doing a price tracker with Python, using CRON to get data daily from Amazon, and save to MySQL and make graphs with Matplotlib.
    Is Plotly better/going to replace Matplotlib? In your opinion?
    Will be interested to see your next video!

  • @mazensleiman3863
    @mazensleiman3863 3 ปีที่แล้ว

    I keep getting ParserError: Error tokenizing data. C error: Expected 1 fields in line 51, saw 2, not sure where is that. is it the csv file from source? any idea how to fix it? thx

  • @SpanishJohn
    @SpanishJohn 2 ปีที่แล้ว

    Hey Keith...trying to get Ur tutorial further but can't manage to use custom fonts...any way you could go deeper?

  • @sdkingma
    @sdkingma 3 ปีที่แล้ว

    Keith, thanks for the video. I didn't know about the fpdf library. I'm having troubles getting your script to run, and I'm not sure if it's because I'm running it in a virtual environment located in your generate-analytics-report directory that I cloned. The error seems to be with kaleido and I'm running it on the Mac. It says 'Users/myname/Projects/Covid Analysis/generate-analytics-report/env/lib/python3.6/site-packages/kaleido/executable/kaleido: line 5: ./bin/kaleido: No such file or directory.' I've looked in that directory and Kaleido is there. Do you have any idea what may be happening?

  • @IsaacBG84
    @IsaacBG84 ปีที่แล้ว

    How would you make a GUI for desktop with this code? or a web app? I want to load csv file and generate report like this