我有一個示例數據框,其中有兩個值(總線和汽車+小巴)在mode column我有兩個問題,第一個是我怎麼能把它分解成兩個數據幀具有單個值,如下所示。第二個問題是因爲我有一個數據框的列表,其中一些發生在input格式中,我怎樣才能寫出一個條件語句他們。 輸入 Dest a b c
Orig Variable Time Mode
1 x y Bus 5
import os
file_dir_path = "D:/Test/list"
for dirName, subdirList, fileList in os.walk(file_dir_path):
if fileList != []:
jpg_name = fileList[0]
if jpg_name!='Thumbs.db':
continu
我得到了與路徑的文本文件,如: /path/to/file.ext 我需要這些路徑分成字典所以key將排除路徑文件和value - 文件名及其擴展名。我曾與下面的代碼管理這樣的: base = {}
with open ('text.txt') as f:
for line in f:
key,val = line.strip('\n').rsplit('/',1)