Python Forum
Sample labels from excel file in order to put them on x-axis and y-axis of a plot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sample labels from excel file in order to put them on x-axis and y-axis of a plot
#10
Thank you for your code! I also use this source: https://stackoverflow.com/questions/4679...ws-to-plot and I am trying this code with the help of your code above:

import pandas as pd
from pathlib import Path
import os
import numpy as np
import matplotlib.pyplot as plt

 
def show_incremental_rows(filename, increment):
    df = pd.read_excel(filename)
    ser = df.iloc[::increment, :]
    print(ser)
 
    fig, ax = plt.subplots()
    ser.plot(ax=ax)
    ax.set_xlabel("date")
    ax.set_ylabel("temperature")
    plt.show() 
 
def main():
    os.chdir(os.path.abspath(os.path.dirname(__file__)))
    show_incremental_rows('/home/hobbyist/Desktop/temperatures.xlsx', 1000)
 
if __name__ == '__main__':
    main()
Although it prints the excel rows in the terminal, it does not plot them...I believe this command
read_excel
reads the whole excel file, so I do not need to specify something more...
Any ideas what is wrong here?
Reply


Messages In This Thread
RE: Sample labels from excel file in order to put them on x-axis and y-axis of a plot - by hobbyist - Sep-12-2021, 05:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python openyxl not updating Excel file MrBean12 1 503 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 596 Feb-07-2024, 12:24 PM
Last Post: Viento
  Search Excel File with a list of values huzzug 4 1,419 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Updating sharepoint excel file odd results cubangt 1 1,013 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  IndexError: index 10 is out of bounds for axis 0 with size 10 Mehboob 11 2,506 Sep-14-2023, 06:54 AM
Last Post: Mehboob
  matplotlib x-axis text move bottom upward jacklee26 3 1,142 May-31-2023, 04:28 AM
Last Post: jacklee26
  Print names in x-axis of a time-series values hobbyist 4 1,360 Apr-22-2023, 09:29 PM
Last Post: deanhystad
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,240 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Save and Close Excel File avd88 0 3,423 Feb-20-2023, 07:19 PM
Last Post: avd88
  Trying to access excel file on our sharepoint server but getting errors cubangt 0 914 Feb-16-2023, 08:11 PM
Last Post: cubangt

Forum Jump:

User Panel Messages

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