
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
숙제하기 부분에서 colab을 이용했는데 엑셀변환이 안되는 방법이 궁금합니다.
내 엑셀 데이터는 고객에 대한 데이터를 담고 있는 시트 한 개로 구성되어 있어. 엑셀 데이터는 고객의 [account name, e-mail, login count, usage time, day care, last login record, number of activities]으로 각각의 컬럼이 구성되어 있어. 임의의 100명에 대한 데이터를 생성해서 파일로 저장하는 python 코드를 openpyxl 라이브러리를 사용해서 만들어 줄 수 있어?
import openpyxl
from faker import Faker
fake = Faker()
# 엑셀 파일 생성
workbook = openpyxl.Workbook()
sheet = workbook.active
# 컬럼 헤더 작성
headers = ["account name", "e-mail", "login count", "usage time", "day care", "last login record", "number of activities"]
sheet.append(headers)
# 데이터 생성 및 작성
for _ in range(100):
account_name = fake.name()
email = fake.email()
login_count = fake.random_int(min=1, max=100)
usage_time = fake.random_int(min=1, max=100)
day_care = fake.company()
last_login_record = fake.date_time_this_year()
num_activities = fake.random_int(min=1, max=10)
data = [account_name, email, login_count, usage_time, day_care, last_login_record, num_activities]
sheet.append(data)
# 엑셀 파일 저장
workbook.save("customer_data.xlsx")
<---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-ac19d602c029> in <cell line: 2>()
1 import openpyxl
----> 2 from faker import Faker
3
4 fake = Faker()
5
ModuleNotFoundError: No module named 'faker'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
