Skip to content

BUG: df.plot works differently for freq="h" and freq="60min" #57587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #58322
natmokval opened this issue Feb 23, 2024 · 4 comments
Open
Tracked by #58322

BUG: df.plot works differently for freq="h" and freq="60min" #57587

natmokval opened this issue Feb 23, 2024 · 4 comments
Assignees
Labels

Comments

@natmokval
Copy link
Contributor

natmokval commented Feb 23, 2024

This bug has not been reported and exists on the latest version of pandas.

Reproducible Examples:
if freq="h"

from pandas import *
import numpy as np

frqncy = 'h'
idx = period_range("01/01/2000", freq=frqncy, periods=4)
df = DataFrame(
    np.array([0, 1, 0, 1]),
    index=idx,
    columns=["A"],
)
res = df.plot()
print(res.freq)
print(df)

output:
output_h

But if freq="60min"

frqncy = '60min'
idx = period_range("01/01/2000", freq=frqncy, periods=4)
df = DataFrame(
    np.array([0, 1, 0, 1]),
    index=idx,
    columns=["A"],
)
res = df.plot()
print(res.freq)
print(df)

the result of plotting is different
output_60min

Expected Behavior:

I think for both freq="h" and freq="60min" plotting should give the same result. The correct behavior should be that what is shown for freq="h".

@natmokval natmokval added Visualization plotting Bug Needs Discussion Requires discussion from core team before further action labels Feb 23, 2024
@m-b-gomes
Copy link

take

@natmokval natmokval removed the Needs Discussion Requires discussion from core team before further action label Feb 24, 2024
@Nrezhang
Copy link
Contributor

Nrezhang commented Apr 3, 2024

take

@Nrezhang
Copy link
Contributor

Hi I am new to contributing, and I was wondering how you test your changes and see the visualizations when you do print(df). Right now, I am running python in the terminal, which i'm sure is not the optimal way, and I can only see
2000-01-01 00:00 0
2000-01-01 01:00 1
2000-01-01 02:00 0
2000-01-01 03:00 1
and not the graph when running print(df)

@Aloqeely
Copy link
Member

I believe the plots display automatically if you are using an interactive environment such as Jupyter notebook.
Otherwise you can import matplotlib.pyplot as plt and then run plt.show() after you have plotted the DataFrame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants