有人试了下Chat GPT,惊了,真的可以提高生产力,取代大部分 stack overflow 功能

起因是有个部门分享的 data 是 power BI 数据源 API,我想把这些数据用 python 读取到 pandas 里面,昨天花了很久研究 M query, 不会转换双引号:(, 拿不到 token,刚刚试了下 ChatGPT 给的 code,一次成功。

太厉害了, 以后不用去 stack overflow 了

我: can you convert power bi m code to python?

ChatGPT: Yes, it is possible to convert Power BI M code to Python. However, the conversion process may not be straightforward and will depend on the specific M code that you are trying to convert. Power BI M code is a proprietary language used in the Power BI platform, while Python is a general-purpose programming language that is widely used in data analysis and scientific computing.

If you have specific M code that you would like to convert to Python, I would recommend that you provide the code and I can try to assist you with the conversion. It would also be helpful to know the reason why you want to convert the M code to Python and what you plan to do with the resulting Python code.

我:
let body1 =”{
“”username””: ” & username &”,
“”password””: “& password &”

}”,

getToken =
Web.Contents(server & tokenAddress, [Content=Text.ToBinary(body1)]),

token1 = “Bearer ” & Text.FromBinary(getToken),

ChatGPT: This Power BI M code is defining several variables and making a web request to get a token. The body1 variable is defining the body of the request as a string containing the username and password values. The getToken variable is making a web request to the server & tokenAddress URL with the body1 content. Finally, the token1 variable is constructing a string by concatenating the Bearer string with the response from the getToken web request.

In Python, you can use the requests library to make web requests and parse the response. Here is an example of how the above Power BI M code could be converted to Python:

Copy code
import requests

username = “your_username”
password = “your_password”
server = “http://your_server.com”
tokenAddress = “/api/get_token”

body1 = {
“username”: username,
“password”: password
}

getToken = requests.post(server + tokenAddress, json=body1)
token1 = “Bearer ” + getToken.text
Note that this is just an example and may not work exactly as shown if the actual Power BI M code is different from what you provided. You may need to adjust the code depending on the details of your specific use case.

声明:本站文章,有些原创,有些转载,如发现侵权侵请联系删除。本站所有原创帖均可复制、搬运,开网站就是为了大家一起乐乐,不在乎版权。对了,本站小水管,垃圾服务器,请不要采集,吐槽君纯属用爱发电,经不起折腾。

给TA打赏
共{{data.count}}人
人已打赏
技术宅

用纯代码自定义WordPress 头像的方法

2022-12-8 8:43:54

技术宅

一个不错的WordPress二次元主题模板:Sakura

2022-12-9 17:22:33

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索