Navidfoumani / ConvTran

This is a PyTorch implementation of ConvTran
MIT License
123 stars 8 forks source link

AttributeError: 'DataFrame' object has no attribute 'series' #4

Closed cacbondioxit closed 7 months ago

cacbondioxit commented 7 months ago

Hello,

I appreciate your work. The syntax df.series in the sourcecode causes the error in pandas version 1.5.3. It seems that It can be simply fixed but I'm not pretty sure I can fix it right now.

# data_loader.py

def load_ford_data(file_path, data_type, norm=True, verbose=1):
    if verbose > 0:
        print("[Data_Loader] Loading data from {}".format(file_path))
    df = pd.read_csv(file_path)
    all_series = df.series.unique()
    data = []

Here's my code. I just did import data_loader and used load_ford_data(). and the traceback says that the syntax df.series makes error.

# My code
from Dataset import data_loader

df_2 = data_loader.load_ford_data("./Dataset/Segmentation/FordChallenge/FordChallenge_Train.csv", data_type=None, norm=False)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [5], line 1
----> 1 df_2 = data_loader.load_ford_data("./Dataset/Segmentation/FordChallenge/FordChallenge_Train.csv", data_type=None, norm=False)
      2 df_2

File ~/workspace/hyungyu/TMCell/TMCell_RNNPrediction_231101/ConvTran/Dataset/data_loader.py:103, in load_ford_data(file_path, data_type, norm, verbose)
    101     print("[Data_Loader] Loading data from {}".format(file_path))
    102 df = pd.read_csv(file_path)
--> 103 all_series = df.series.unique()
    104 data = []
    106 for series in all_series:

File ~/anaconda3/envs/cell/lib/python3.8/site-packages/pandas/core/generic.py:5902, in NDFrame.__getattr__(self, name)
   5895 if (
   5896     name not in self._internal_names_set
   5897     and name not in self._metadata
   5898     and name not in self._accessors
   5899     and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5900 ):
   5901     return self[name]
-> 5902 return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'series'

It looks like just simple problem but I thought It's necessary to report here. Thank you!

Navidfoumani commented 7 months ago

Hi Kim,

Thanks for the report. It works fine with Pandas version 1.5.3 on my machine. Could you check if other dependent libraries, like NumPy, are up to date on your end?

Let me know if you need further assistance.

Appreciate it! Navid

cacbondioxit commented 7 months ago

Hello Navid, I appreciate your reply.

I just made new conda virtual environment with python 3.8 for running ConvTran. I installed the dependencies in requirements file there, and... that's it. I checked my numpy version with np.__version__. it was 1.24.3, which was same with requirements.txt.

The reason why I reported this issue is here: When I brought another pandas DataFrame and ran df.series, it makes same error in another envs. I googled if pd.DataFrame has attribute 'series' indeed, and it seems like pd.DataFrame has no attribute like 'series'. So I'm still wondering why it works fine with your machine, and it doesn't with mine.

Let me know if there's something else I should tell you more, I still need help. I should say I appreciate your work again. Thank you.

Hyungyu Kim

Navidfoumani commented 7 months ago

Hi again,

Thank you for providing additional details. I believe I've identified the issue. 'series' is not an attribute of the Pandas DataFrame; rather, it represents one of the columns in your DataFrame, possibly from the Ford challenge or HAR datasets.

To access this column, you can use df['series'] instead of df.series to avoid the error. ['series' here denotes a specific column, not a DataFrame attribute].

If you have any further questions or encounter any more issues, feel free to reach out.

Best regards, Navid

cacbondioxit commented 7 months ago

Hello Navid, Now I got what is going on df.series. I never expected 'series' would be the column name. Thanks for your support!

Hyungyu Kim