Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FutureWarning: The behavior of 'to_datetime' with 'unit' when parsing strings is deprecated. #4

Open
rasta-mouse opened this issue Oct 18, 2023 · 0 comments

Comments

@rasta-mouse
Copy link

FutureWarning error with kucoin-cli 1.4.6 and pandas 2.0.2.

---------------------------------------------------------------------------
FutureWarning                             Traceback (most recent call last)
[c:\Users\x\x\x.ipynb] Cell 18 line 1
----> 1 ohlcv_df = client.ohlcv(
      2      tickers=["BTC-USDT", "ETH-USDT"],
      3      start="2022-01-01",
      4      end="2022-01-02",
      5      interval="1hour"
      6  )

File [c:\Python311\Lib\site-packages\kucoincli\client.py:518], in Client.ohlcv(self, tickers, start, end, interval, ascending, warning)
    516     break
    517 df = pd.DataFrame(resp["data"])
--> 518 df[0] = pd.to_datetime(df[0], unit="s", origin="unix")
    519 df = df.rename(
    520     columns={
    521         0: "time",
   (...)
    528     }
    529 ).set_index("time")
    530 df_pages.append(df.astype(float))

File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\tools\datetimes.py:1050], in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache)
   1048         result = arg.map(cache_array)
   1049     else:
-> 1050         values = convert_listlike(arg._values, format)
   1051         result = arg._constructor(values, index=arg.index, name=arg.name)
   1052 elif isinstance(arg, (ABCDataFrame, abc.MutableMapping)):

File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\tools\datetimes.py:427], in _convert_listlike_datetimes(arg, format, name, utc, unit, errors, dayfirst, yearfirst, exact)
    425     if format is not None:
    426         raise ValueError("cannot specify both format and unit")
--> 427     return _to_datetime_with_unit(arg, unit, name, utc, errors)
    428 elif getattr(arg, "ndim", 1) > 1:
    429     raise TypeError(
    430         "arg must be a string, datetime, list, tuple, 1-d array, or Series"
    431     )

File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\tools\datetimes.py:539], in _to_datetime_with_unit(arg, unit, name, utc, errors)
    537     else:
    538         arg = arg.astype(object, copy=False)
--> 539         arr, tz_parsed = tslib.array_with_unit_to_datetime(arg, unit, errors=errors)
    541 if errors == "ignore":
    542     # Index constructor _may_ infer to DatetimeIndex
    543     result = Index._with_infer(arr, name=name)

File [~\AppData\Roaming\Python\Python311\site-packages\pandas\_libs\tslib.pyx:309], in pandas._libs.tslib.array_with_unit_to_datetime()

FutureWarning: The behavior of 'to_datetime' with 'unit' when parsing strings is deprecated. In a future version, strings will be parsed as datetime strings, matching the behavior without a 'unit'. To retain the old behavior, explicitly cast ints or floats to numeric type before calling to_datetime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant