代码之家  ›  专栏  ›  技术社区  ›  Chicken Sandwich No Pickles

使用M或Python的PowerBI正则表达式

  •  0
  • Chicken Sandwich No Pickles  · 技术社区  · 4 年前

    我以前从未在PowerBI中使用过Python,但我使用过Python。不过,我对Python或m语言解决方案很满意。

    EntryTime
    12:00:00 - 01:10:00
    01:00:30 - 05:10:50
    2020-11-03 R
    2010-03-31 R
    2020-04-01 R
    

    我想用替换包含此格式且不区分大小写的所有值 NULL

    yyyy-MM-dd( )+[R] 
    

    如何使用M或Python在PowerBI中实现这一点?请非常具体,因为我以前没有在PowerBI中使用Python。

    0 回复  |  直到 4 年前
        1
  •  3
  •   Arun Palanisamy    4 年前

    M 没有执行任何正则表达式操作的本机函数。你可以用 Python

    步骤1:更改的列数据类型 EntryTime Text

    enter image description here

    步骤2:转到 Transform -&燃气轮机; Run Python Script

    ok

    # 'dataset' holds the input data for this script
    import pandas as pd
    pat = r'\d{4}-\d{2}-\d{2} R'
    dataset["New"] = dataset["EntryTime"].str.replace(pat,'')
    

    第四步:你将得到一个窗口与 Name Value

    enter image description here

    步骤5:单击 Table 在下面 价值观 专栏。您将得到如下所示的结果。

    enter image description here