CorySimon / pyIAST

Ideal Adsorbed Solution Theory
MIT License
46 stars 32 forks source link

Pandas FutureWarning #10

Open danieleongari opened 5 years ago

danieleongari commented 5 years ago

Using the latest version (8ebc14) with pandas>=0.24.0 in python 2.7 the following FutureWarning shows up:

~/.virtualenvs/aiidapy/local/lib/python2.7/site-packages/pyiast/isotherms.py:434: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  }, index=[0]), df

Can you please update to solve the issue? Thanks!

SimonEnsemble commented 5 years ago

I think this is b/c you have an irrelevant column in your dataframe you're passing in:

import pandas as pd

df1 = pd.DataFrame()
df1["P"] = [1.0, 2.0]
df1["n"] = [3.0, 4.0]
#  df1["irrelevant column"] = [30.0, 40.0]

df2 = pd.DataFrame()
df2["P"] = [3.0, 4.0]
df2["n"] = [5.0, 6.0]

df = pd.concat([df1, df2]) # gives warning only if line above is not commented out

It wants us to pass sort=True or sort=False, which determines whether or not to sort the column names when joining (an outer join). I don't think it matters. Agree @ltalirz?

Another option is to do instead df = pd.concat([df1, df2], join="inner") which will destroy the extraneous columns you are providing when joining the zero pressure point. (extraneous = columns not pertaining to pressure_key or loading_key)

ltalirz commented 5 years ago

It's probably not important - as the warning says, simply pass sort=True and to retain the current behavior and silence the warning. @danieleongari set up a PR?