# 常用python 语法

By [KeepLearning](https://paragraph.com/@keeplearning-2) · 2024-01-14

---

1，注意中括号

df = pd.read\_csv(path, parse\_dates=\['candle\_begin\_time'\])

2，时间修改

df\['candle\_begin\_time'\] = df\['candle\_begin\_time'\] - pd.Timedelta(hours=8)

3，删掉某一列

df.drop('symbol\_type', axis=1, inplace=True)

4，某一列的replace，注意需要加上str

df\['symbol'\] = df\['symbol'\].str.replace('USDT', '-USDT')

5，比较两个文件夹

files1 = set(os.listdir(xingbuxing\_spot\_path))

files2 = set(os.listdir(menglong\_spot\_path))

unique\_to\_folder1 = files1 - files2

unique\_to\_folder2 = files2 - files1

6，文件夹下的所有文件，也可以统计个数，list(files1)

files1 = os.listdir(xingbuxing\_spot\_path)

7，最左下角数值

df.iloc\[-1, 0\]

---

*Originally published on [KeepLearning](https://paragraph.com/@keeplearning-2/python-3)*
