我正在尝试用 Python 替换这里的字符串。
这是我的输入 -
MyString = \\ServerA\DriveB\5.FolderC\A.TXT
Run Code Online (Sandbox Code Playgroud)
我希望我的输出是这样的
OutputString = //ServerA/DriveB/5.FolderC/A.TXT
Run Code Online (Sandbox Code Playgroud)
我尝试了替换方法,但不起作用。有没有可以转换的函数?请帮我解决这个问题。
该代码尝试过,
MyString = '\\ServerA\DriveB\5.FolderC\A.TXT'
Output_String = MyString.replace('\', '//')
print(Output_String)
Run Code Online (Sandbox Code Playgroud)
语法错误:扫描字符串文字时 EOL
我们如何使用 pandas 检查是否有任何列是日期时间数据类型列,然后仅将该列转换为日期格式字符串 (yyyy-mm-dd) 数据类型列。
我有多个日期时间列。因此,我无法按列名称进行更改。但更喜欢一种检查然后更改它的方式。
请帮我解决这个问题。
我有一个要求,我有三个输入文件,需要在两个文件合并到一个数据框之前加载它们在Pandas数据框内.
文件扩展名总是更改,可能是.txt一次,而.xlsx或.csv则是另一次.
如何平行运行此过程以节省等待/加载时间?
这是我目前的代码,
from time import time # to measure the time taken to run the code
start_time = time()
Primary_File = "//ServerA/Testing Folder File Open/Report.xlsx"
Secondary_File_1 = "//ServerA/Testing Folder File Open/Report2.csv"
Secondary_File_2 = "//ServerA/Testing Folder File Open/Report2.csv"
import pandas as pd # to work with the data frames
Primary_df = pd.read_excel (Primary_File)
Secondary_1_df = pd.read_csv (Secondary_File_1)
Secondary_2_df = pd.read_csv (Secondary_File_2)
Secondary_df = Secondary_1_df.merge(Secondary_2_df, how='inner', on=['ID'])
end_time = time()
print(end_time - start_time)
Run Code Online (Sandbox Code Playgroud)
加载我的primary_df和secondary_df需要大约20分钟.所以,我正在寻找一种有效的解决方案,可能使用并行处理来节省时间.我通过阅读操作计时,大部分时间大约需要18分45秒.
硬件配置: - Intel i5处理器,16 GB Ram和64位OS …
我正在尝试将图像添加到电子邮件正文。
我正在使用 Outlook 16 和 Python 3.7 来执行此操作。
邮件从邮箱发送。
这是我发送电子邮件的代码功能,以及如何在电子邮件末尾添加图像。
def send_email(sender,recipient):
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = Subject_Req
mail.HTMLBody = Content_Email
mail.SentOnBehalfOfName = sender
mail.GetInspector
mail.Send()
Run Code Online (Sandbox Code Playgroud)
图像存在于我的本地网络中:- C:\Users\Sid\AppData\Roaming\Microsoft\Signatures\My Project\image001.png
图像只不过是我想放在 HTML 正文最后一部分的徽标。
所以基本上从函数来看,它将是 Content_Email + 此图像。
我尝试了一些代码,它的作用是:- 它在末尾发送一个“X”标记代替图像本身给收件人。
当我将它发送给自己时,它会放置“X”标记,但我可以选择右键单击下载图片并获取图像。
我想要做的是,在两种情况下都使用图像而不是“X”,而用户不必访问该图像。
我如何使用 Python 做到这一点。这里的解决方案似乎与 VBA 一起使用:https : //www.experts-exchange.com/questions/26481413/Problem-inserting-HTML-images-into-the-body-of-a-messge.html
I have 2 tables connected to each other through col A. I want to match the column C with Col A and get the value of Col B.
For Example,
Table 1
ColA ColB Colc
a a1 b
a b1 c
c c1 a
Run Code Online (Sandbox Code Playgroud)
Table2
ColA ColB
a a1
b b1
c c1
Run Code Online (Sandbox Code Playgroud)
Now, I have already created relationships between Table2 and Table1 for my other calculations connecting both the tables with the colA.
现在,我尝试将Table1中的ColC与Table2中的ColA匹配,并从Table2中返回ColB的值作为MatchedOutput。
预期输出表1
ColA ColB Colc MatchedOutput …Run Code Online (Sandbox Code Playgroud) 假设我有一张这样的桌子 - [订单]
Date Amount Category
12/12/2017 100 A
12/12/2017 200 B
12/12/2017 300 C
1/1/2018 400 A
1/1/2018 500 B
Run Code Online (Sandbox Code Playgroud)
我有一个用于类别的切片器。
如果只选择了一个值,那么像这样的度量将起作用
CALCULATE(SUM(Orders[Amount]),FILTER(ALL(Orders), Orders[Category] = SelectedValue(Category))).
Run Code Online (Sandbox Code Playgroud)
选择多个值时,您将如何通过DAX测量内部?
我有两个数据帧,
DF1
ID Key
1 A
2 B
3 C
4 D
Run Code Online (Sandbox Code Playgroud)
DF2
ID Key
1 D
2 C
3 B
4 E
Run Code Online (Sandbox Code Playgroud)
现在,如果在df2中找到df1中的键,则新列将具有找不到的值
带输出数据帧的df1成为,
ID Key Result
1 A Not Found
2 B Found
3 C Found
4 D Found
Run Code Online (Sandbox Code Playgroud)
我们怎么能用熊猫做到这一点?这不是ID的连接/连接/合并.
我正在动态选择列表框中的一个项目。现在,当选择该项目时,所选项目必须显示在列表框的前端。更像是滚动条必须移动到该项目。这样最终用户就会知道该项目已被选择。我尝试使用 SetFocus 但收到错误:
对象不支持此属性或方法
错误发生在.SetFocus(idx) = True下面一行:
ReqSearchvalue = Range("B" & reqrow).Value
Sheets("Main").Activate
With Sheets("Main").Ent_ListBox
For i = 0 To .ListCount - 1
Value = .List(i)
If Value = ReqSearchvalue Then
idx = i
Exit For
End If
Next i
.Selected(idx) = True
.SetFocus(idx) = True
End With
Run Code Online (Sandbox Code Playgroud)
请分享您的想法。
我有一个要求,我在尝试计算值并将它们放在数据透视表中.
这是我的数据帧,
Cola Colb
Apple Rippened
Orange Rippened
Apple UnRippened
Mango UnRippened
Run Code Online (Sandbox Code Playgroud)
我希望输出像这样,
Rippened UnRippened
Apple 1 1
Mango 0 1
Orange 1 0
Run Code Online (Sandbox Code Playgroud)
请分享您的想法.
我有一个要求,我必须循环遍历文本字段中的每个字符
例如:
| 输入 | 预期输出 |
|---|---|
| a#123456;12341 | 123456;12341 |
| a123456 12341bd | 123456;12341 |
| a2017d 12341ds | 12341 |
| a123456/12341bd | 123456;12341 |
| 不适用 | 无效的 |
基本上我在这里清理我的数据:
注意:-我的步骤可能不正确,但我的预期输出是我希望从数据中获得的结果。
我们如何使用 Power BI 中的 DAX 或查询编辑器来做到这一点?