수행합니다는 왜 두 개의 디스크가있는 PC가 팬더 파이썬 사용 디스크 공간
- 110기가바이트 SSD를
- 1TB HDD SSD를 무료 18기가바이트 주위에있다
.
아래의 파이썬 코드를 실행하면 내 SSD의 모든 공간을 "사용"합니다 (1GB 만 사용 가능). 이 코드는 폴더의 모든 SAS 파일을 반복하고 작업별로 그룹을 수행하며 각 파일의 결과를 하나의 큰 데이터 프레임에 추가합니다.
import pandas as pd
import os
import datetime
import numpy as np
#The function GetDailyPricePoints does the following:
#1. Imports file
#2. Creates "price" variable
#3. Performs a group by
#4. Decode byte variables and convert salesdate to date type (if needed)
def GetDailyPricePoints(inpath,infile):
intable = pd.read_sas(filepath_or_buffer=os.path.join(inpath,infile))
#Create price column
intable.loc[intable['quantity']!=0,'price'] = intable['salesvalue']/intable['quantity']
intable['price'] = round(intable['price'].fillna(0.0),0)
#Create outtable
outtable = intable.groupby(["salesdate", "storecode", "price", "barcode"]).agg({'key_row':'count', 'salesvalue':'sum', 'quantity':'sum'}).reset_index().rename(columns = {'key_row':'Baskets', 'salesvalue':'Sales', 'quantity':'Quantity'})
#Fix byte values and salesdate column
for column in outtable:
if not column in list(outtable.select_dtypes(include=[np.number]).columns.values): #loop non-numeric columns
outtable[column] = outtable[column].where(outtable[column].apply(type) != bytes, outtable[column].str.decode('utf-8'))
elif column=='salesdate': #numeric column and name is salesdate
outtable[column] = pd.to_timedelta(outtable[column], unit='D') + pd.Timestamp('1960-1-1')
return outtable
inpath = r'C:\Users\admin\Desktop\Transactions'
outpath = os.getcwd() + '\Export'
outfile = 'DailyPricePoints'
dirs = os.listdir(inpath)
outtable = pd.DataFrame()
#loop through SAS files in folder
for file in dirs:
if file[-9:] == '.sas7bdat':
outtable.append(GetDailyPricePoints(inpath,file,decimals))
정확하게 디스크 공간을 사용하고 있는지 알고 싶습니다. 또한이 임시 작업이 저장되는 경로를 내 HDD의 경로로 변경하고 싶습니다.
페이징 할 수 있습니까? – shanmuga