最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How dtype parameter within sd2df_DISK() function works - Stack Overflow

programmeradmin5浏览0评论

I have started working with an EL process that transfers data from SAS to Azure using SASPy.

Regarding one specific table, I have found out that the transference of some string fields is forced via dtype within sd2df_DISK(). This works for these strings fields but interferes in the transference of some other date fields, which are turned also into strings - I don't know why.

I'd like to include these date fields in the dtype dictionary to assure they remain as dates, but I can't figure out how to depict the data type: 'date', 'datetime' or 'datetime64[ns]' don't seem to work.

The dtype dictionary currently looks like this (it comes from a .yml file):

TABLE_NAME:  {'str_field_1': 'str', ..., 'str_field_n': 'str'}

So I guess I should modify it this way:

TABLE_NAME:  {'date_field_1': 'correct_date_type', ..., 'str_field_1': 'str', ..., 'str_field_n': 'str'}

Regarding the comment by Stu Sztukowski, I get this:

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 144 entries, 0 to 143
Data columns (total 2 columns):
 #   Column  Non-Null Count  Dtype
---  ------  --------------  -----
 0   DATE    144 non-null    datetime64[ns]
 1   AIR     144 non-null    float64
dtypes: datetime64[ns](1), float64(1)
memory usage: 2.4 KB
发布评论

评论列表(0)

  1. 暂无评论