# Pandas dataframe column is loaded with different type than KNIME table

**URL:** <https://forum.knime.com/t/pandas-dataframe-column-is-loaded-with-different-type-than-knime-table/40350>\
**Category:** KNIME Analytics Platform\
**Tags:** python, bug\
**Created:** [March 2, 2022, 4:05pm UTC](https://forum.knime.com/t/pandas-dataframe-column-is-loaded-with-different-type-than-knime-table/40350 "2022-03-02T16:05:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![uie63112](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uie63112/32/33605_2.png) [@uie63112](https://forum.knime.com/u/uie63112)\
**Post date:** [March 2, 2022, 4:05pm UTC](https://forum.knime.com/t/pandas-dataframe-column-is-loaded-with-different-type-than-knime-table/40350/1 "2022-03-02T16:05:19Z")

</div>

Hi,  
some of my columns in a KNIME python script are loaded via Pandas with a different data type than the original KNIME table, this can be seen in this screenshot (compare input variables - int, and console output float64):

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/1/615473f2f362b590506b9e6791860393e12d7a0d.png)

Can somebody think of a solution to convert it into that type again (within a component, so somehow with dynamic column names)? Currently, this causes problems with a model that expects similar data types than before.

---

<div class="post-metadata">

**Author:** ![MarcelW](https://forum-cdn.knime.com/user_avatar/forum.knime.com/marcelw/32/352_2.png) [@MarcelW](https://forum.knime.com/u/MarcelW)\
**Post date:** [March 2, 2022, 6:16pm UTC](https://forum.knime.com/t/pandas-dataframe-column-is-loaded-with-different-type-than-knime-table/40350/2 "2022-03-02T18:16:31Z")

</div>

Hi @uie63112,

Does your integer column contain missing values? If so, they are automatically converted into NaNs, which implies converting the entire column into float. You can avoid that in several ways. One way built into the node would be to convert missings into predefined integer placeholder values (“sentinels”) instead. This is described in more detail in the “Missing values (Integer, Long)” section of the [node description](https://kni.me/n/6L0w9_dCmFzbn-rx).  
Alternatively, you could handle missing values outside of the node using e.g. the [Missing Value](https://kni.me/n/uVmaGQkzUOFCTqUe) node. Finally, the new [Python Script (Labs)](https://kni.me/n/dQ5A2CMdtDriX4ro) node offers an alternative, more type-safe pyarrow API besides the pandas one, where missings are represented explicitly. This might also be interesting to you (note that it is not recommended to use Labs nodes in production, though).

Marcel

---

<div class="post-metadata">

**Author:** ![uie63112](https://forum-cdn.knime.com/user_avatar/forum.knime.com/uie63112/32/33605_2.png) [@uie63112](https://forum.knime.com/u/uie63112)\
**Post date:** [March 3, 2022, 6:42am UTC](https://forum.knime.com/t/pandas-dataframe-column-is-loaded-with-different-type-than-knime-table/40350/3 "2022-03-03T06:42:32Z")

</div>

Thanks a lot @MarcelW, I really appreciate your fast, detailed answer 😄

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [March 10, 2022, 6:42am UTC](https://forum.knime.com/t/pandas-dataframe-column-is-loaded-with-different-type-than-knime-table/40350/4 "2022-03-10T06:42:33Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
