■ StringMethods 클래스에서 [] 연산자를 사용해 문자열을 구하는 방법을 보여준다.
▶ main.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import pandas as pd dataFrame = pd.read_excel("tips.xlsx", index_col = 0) stringMethods = dataFrame["sex"].str series = stringMethods[0:1] print(series) """ 0 F 1 M 2 M 3 M 4 F .. 239 M 240 F 241 M 242 M 243 F Name: sex, Length: 244, dtype: object """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
defusedxml==0.7.1 et_xmlfile==2.0.0 numpy==2.1.3 odfpy==1.4.1 openpyxl==3.1.5 pandas==2.2.3 python-calamine==0.2.3 python-dateutil==2.9.0.post0 pytz==2024.2 pyxlsb==1.0.10 six==1.16.0 tzdata==2024.2 xlrd==2.0.1 XlsxWriter==3.2.0 |
※ pip install "pandas[excel]" 명령을 실행했다.