<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python visual script handling dates as strings in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Python-visual-script-handling-dates-as-strings/m-p/3147068#M41873</link>
    <description>&lt;P&gt;My bad, I realized that doing data editing is not wise inside the python script. You should edit the data in the ways you need with dax calculations and then feed those into the python visual!&lt;/P&gt;</description>
    <pubDate>Wed, 22 Mar 2023 11:51:11 GMT</pubDate>
    <dc:creator>314mp_M0th4</dc:creator>
    <dc:date>2023-03-22T11:51:11Z</dc:date>
    <item>
      <title>Python visual script handling dates as strings</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Python-visual-script-handling-dates-as-strings/m-p/3146898#M41870</link>
      <description>&lt;P&gt;Hello, I'm trying to insert a python visual I created (and works outside power BI), and insert into a power bi python visual. This is a gantt chart. When I try to run it it gives me the following error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error Message:&lt;BR /&gt;&lt;STRONG&gt;Python script error.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;TypeError: unsupported operand type(s) for -: 'str' and 'str'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;During handling of the above exception, another exception occurred:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TypeError: unsupported operand type(s) for -: 'str' and 'str'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect it is treating the date columns as a string. In the data model however, the dates are formatted as short dates and have the data type date. Can anyone explain what might be happening?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A piece of the code where i expect the error to be happening:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;today = pd.Timestamp.today()&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;year_from_today = today + datetime.timedelta(days = 365)&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;proj_start = df["Verkefni hefst"].min()&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;df["start_num"] = (df["Verkefni hefst"] - proj_start).dt.days&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;df['end_num'] = (df["Verkefni lýkur"]-proj_start).dt.days&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;# days between start and current progression of each task&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;df['current_num'] = (df['Dagar í verkefni'] * df.Lokið)&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;df['days_start_to_end'] = df.end_num - df.start_num&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Many thanks in advance!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Mar 2023 10:42:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Python-visual-script-handling-dates-as-strings/m-p/3146898#M41870</guid>
      <dc:creator>314mp_M0th4</dc:creator>
      <dc:date>2023-03-22T10:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Python visual script handling dates as strings</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Python-visual-script-handling-dates-as-strings/m-p/3147068#M41873</link>
      <description>&lt;P&gt;My bad, I realized that doing data editing is not wise inside the python script. You should edit the data in the ways you need with dax calculations and then feed those into the python visual!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 11:51:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Python-visual-script-handling-dates-as-strings/m-p/3147068#M41873</guid>
      <dc:creator>314mp_M0th4</dc:creator>
      <dc:date>2023-03-22T11:51:11Z</dc:date>
    </item>
  </channel>
</rss>

