pandas icon indicating copy to clipboard operation
pandas copied to clipboard

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

Open natmokval opened this issue 1 year ago • 4 comments

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 avatar Feb 23 '24 15:02 natmokval

take

m-b-gomes avatar Feb 23 '24 17:02 m-b-gomes

take

Nrezhang avatar Apr 03 '24 17:04 Nrezhang

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)

Nrezhang avatar Apr 21 '24 17:04 Nrezhang

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.

Aloqeely avatar May 21 '24 16:05 Aloqeely