Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

with open(path, 'wb') as fp:
       pickle.dump(df1, fp)

with open(path, 'rb') as fp:
       df2 = pickle.load(fp)

asset_frame_equal(df1, df2)

Issue Description

Given df1 and write and read it into a pickle as

with open(path, 'wb') as fp:
       pickle.dump(df1, fp)

with open(path, 'rb') as fp:
       df2 = pickle.load(fp)

asset_frame_equal(df1, df2)

Gives an error since one column was reordered (shifted to the end)

Expected Behavior

give me df2 as the same as df1. This occurred when I wrote the unit test; however, in the jupyter notebook, it is not a problem. It shows the same.

Installed Versions

Replace this line with the output of pd.show_versions() pandas: 1.1.4 python 3.8.15.final.0 OS: linux OS release: 5.4.0-146-generic

Comment From: MarcoGorelli

thanks for the report

can't reproduce

In [73]: df1 = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})

In [74]: path ='tmp.pkl'

In [75]: with open(path, 'wb') as fp:
    ...:        pickle.dump(df1, fp)
    ...:
    ...: with open(path, 'rb') as fp:
    ...:        df2 = pickle.load(fp)
    ...:
    ...: pd.testing.assert_frame_equal(df1, df2)

your example isn't reproducible, and there's a typo (asset instead of assert) so I'm going to close and assume the problem's elsewhere. can reopen if you post a reproducible example

Comment From: EGanji

I cannot give the data I have company privacy. However, there is no typo in the code; I may have one here. The columns have some NAN elements. The df has more than 15 columns, and this happened for the last three columns. I cannot explain more.

Comment From: MarcoGorelli

you can narrow down and anonymise your data