Arturus / kaggle-web-traffic

1st place solution
MIT License
1.82k stars 667 forks source link

make_features.py @ step 2 #30

Closed timhuang1204 closed 5 years ago

timhuang1204 commented 5 years ago

Hi thank for your code to let us learn

here have a problem when I run python make_features.py data/vars --add_days=63 it's show error:

Traceback (most recent call last):
  File "D:\Miniconda3\lib\site-packages\pandas\core\indexes\base.py", line 757, in astype
    dtype=dtype)
  File "D:\Miniconda3\lib\site-packages\pandas\core\indexes\base.py", line 308, in __new__
    dtype=dtype, **kwargs)
  File "D:\Miniconda3\lib\site-packages\pandas\core\indexes\datetimes.py", line 303, in __new__
    int_as_wall_time=True)
  File "D:\Miniconda3\lib\site-packages\pandas\core\arrays\datetimes.py", line 376, in _from_sequence
    ambiguous=ambiguous, int_as_wall_time=int_as_wall_time)
  File "D:\Miniconda3\lib\site-packages\pandas\core\arrays\datetimes.py", line 1720, in sequence_to_dt64ns
    dtype = _validate_dt64_dtype(dtype)
  File "D:\Miniconda3\lib\site-packages\pandas\core\arrays\datetimes.py", line 2016, in _validate_dt64_dtype
    .format(dtype=dtype))
ValueError: Unexpected value for 'dtype': 'datetime64[D]'. Must be 'datetime64[ns]' or DatetimeTZDtype'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "make_features.py", line 349, in <module>
    run()
  File "make_features.py", line 273, in run
    df, nans, starts, ends = prepare_data(args.start, args.end, args.valid_threshold)
  File "make_features.py", line 176, in prepare_data
    df = read_x(start, end)
  File "make_features.py", line 75, in read_x
    df = read_all()
  File "make_features.py", line 46, in read_all
    df = read_file('train_2')
  File "make_features.py", line 37, in read_file
    df.columns = df.columns.astype('M8[D]')
  File "D:\Miniconda3\lib\site-packages\pandas\core\indexes\base.py", line 760, in astype
    raise TypeError(msg.format(name=type(self).__name__, dtype=dtype))
TypeError: Cannot cast Index to dtype M8[D]

how can I to solve?

OS : win 10 Python Version : 3.6.8 numba : 0.42.0 numpy : 1.16.2 pandas : 0.24.1

59ranjbar commented 5 years ago

@timhuang1204 Hi Tim, I have the same issue as you do. Did you find any solution to yours? Appreciate any help.