我期待这段代码:
if (!File.Exists(fullFileName))
{
File.Create(fullFileName);
}
File.SetAttributes(fullFileName, FileAttributes.Compressed);
设置此标志:
但它没有...我做错了什么?如何在文件上设置该标志?
"无法更改File对象的压缩状态 使用SetAttributes方法。"
显然,在使用静态File.SetAttributes时它不起作用。
鉴于此,如何实现这一目标?
答案 0 :(得分:0)
属性是位掩码。
试试这个:
File.SetAttributes(fullFileName,
File.GetAttributes(fullFileName) | FileAttributes.Compressed);
(在Examples
import pandas as pd
import numpy as np
df_dict = dict(A=[(1.55, 2.07, 2.20, 2.23), (0.67, 1.10, 1.73, 1.35), (2.92, 1.98, 2.30, 2.66)],
B=[(1.55, 0.0086, 0.078, 0.12), (0.672, 0.142, 0.0166, 0.0173), (1.97, 0.0094, 0.1648, 0.016)])
df = pd.DataFrame(df_dict)
Out[180]:
A B
0 (1.55, 2.07, 2.2, 2.23) (1.55, 0.0086, 0.078, 0.12)
1 (0.67, 1.1, 1.73, 1.35) (0.672, 0.142, 0.0166, 0.0173)
2 (2.92, 1.98, 2.3, 2.66) (1.97, 0.0094, 0.1648, 0.016)
def apply_func(row):
return row.B[np.array(row.A).argmax()]
df['C'] = df.apply(apply_func, axis=1)
Out[182]:
A B C
0 (1.55, 2.07, 2.2, 2.23) (1.55, 0.0086, 0.078, 0.12) 0.1200
1 (0.67, 1.1, 1.73, 1.35) (0.672, 0.142, 0.0166, 0.0173) 0.0166
2 (2.92, 1.98, 2.3, 2.66) (1.97, 0.0094, 0.1648, 0.016) 1.9700
下找到。)