个人昵称:lxw-pro
个人主页:欢迎关注 我的主页
个人感悟: “失败乃成功之母”,这是不变的道理,在失败中总结,在失败中成长,才能成为IT界的一代宗师。
现在呀,虽说已经大面积的使用微信支付、支付宝支付等,可要想微信、支付宝等留有余额,还是离不开我们的存款,存款的话也得有现金,当然,自动取款机还是依旧那么方便 ,“自己动手,丰衣足食”,那么,我们的自动取款机又是怎么知道你存了这么多,怎么清楚地知道你的余额的呢,下面我们来康康这所谓的简易模拟系统叭!
import datetime
class Bank(object):
account_log = []
def __init__(self, name):
self.name = name
def deposit(self, amount): # 存钱
user.balance += amount
self.write_log('存钱', amount)
def withdrawal(self, amount): # 取钱
if amount > user.balance:
print("余额不足")
else:
user.balance -= amount
self.write_log('取钱', amount)
def write_log(self, type, amount): # 写日志
now = datetime.datetime.now()
ct = now.strftime("%Y-%m-%d %H:%M:%S")
data = [self.name, user.name, ct, type, amount, f"{user.balance:.2f}"]
Bank.account_log.append(data)
class User(object):
def __init__(self, name, balance):
self.name = name
self.balance = balance
def print_log(self):
for item in Bank.account_log:
print(item)
def show_menu():
menu = '''
0: 退出
1: 存款
2: 取款
3: 打印交易信息
'''
print(menu)
bank = Bank("贵阳银行")
user = User('lxw-pro', 520)
while True:
show_menu()
num = int(input("请输入菜单编号:"))
if num == 0:
print("退出系统")
break
elif num == 1:
print("存款")
amount = float(input("请输入存款金额:"))
bank.deposit(amount)
print(f"当前金额是{user.balance:.2f}")
elif num == 2:
print("取款")
amount = float(input("请输入取款金额:"))
bank.withdrawal(amount)
print(f"当前金额是{user.balance:.2f}")
elif num == 3:
print("查看记录")
user.print_log()
else:
print("输入有误!")
————————————————————————————————————————————
# -*- coding = utf-8 -*-
# @Time : 2022/7/29 15:15
# @Author : lxw_pro
# @File : pandas-11 练习.py
# @Software : PyCharm
import pandas as pd
import matplotlib.pyplot as plt
lxw = pd.read_excel("site.xlsx")
print(lxw)
Unnamed: 0 Unnamed: 0.1 create_dt ... yye sku_cost_prc lrl
0 0 1 2016-11-30 ... 8.8 6.77 30.00%
1 1 2 2016-11-30 ... 7.5 5.77 30.00%
2 2 3 2016-11-30 ... 5.0 3.85 30.00%
3 3 4 2016-11-30 ... 19.6 7.54 30.00%
4 4 5 2016-12-02 ... 13.5 10.38 30.00%
.. ... ... ... ... ... ... ...
751 751 752 2016-12-31 ... 1.0 0.77 30.00%
752 752 753 2016-12-31 ... 2.0 1.54 30.00%
753 753 754 2016-12-31 ... 1.0 0.77 30.00%
754 754 755 2016-12-31 ... 7.6 2.92 30.00%
755 755 756 2016-12-31 ... 3.3 2.54 30.00%
[756 rows x 8 columns]
lxw['sku_cost_prc'].plot(kind='kde')
plt.show()
print(-lxw['sku_cost_prc'].diff())
0 NaN
1 1.00
2 1.92
3 -3.69
4 -2.84
...
751 3.13
752 -0.77
753 0.77
754 -2.15
755 0.38
Name: sku_cost_prc, Length: 756, dtype: float64
print(-lxw['sku_cost_prc'].pct_change())
0 NaN
1 0.147710
2 0.332756
3 -0.958442
4 -0.376658
...
751 0.802564
752 -1.000000
753 0.500000
754 -2.792208
755 0.130137
Name: sku_cost_prc, Length: 756, dtype: float64
data = lxw.set_index('create_dt')
print(data)
Unnamed: 0 Unnamed: 0.1 sku_cnt ... yye sku_cost_prc lrl
create_dt ...
2016-11-30 0 1 1.0 ... 8.8 6.77 30.00%
2016-11-30 1 2 1.0 ... 7.5 5.77 30.00%
2016-11-30 2 3 1.0 ... 5.0 3.85 30.00%
2016-11-30 3 4 2.0 ... 19.6 7.54 30.00%
2016-12-02 4 5 1.0 ... 13.5 10.38 30.00%
... ... ... ... ... ... ...
2016-12-31 751 752 1.0 ... 1.0 0.77 30.00%
2016-12-31 752 753 1.0 ... 2.0 1.54 30.00%
2016-12-31 753 754 1.0 ... 1.0 0.77 30.00%
2016-12-31 754 755 2.0 ... 7.6 2.92 30.00%
2016-12-31 755 756 1.0 ... 3.3 2.54 30.00%
[756 rows x 7 columns]
sku_cost_prc
)jz = data['sku_cost_prc'].rolling(10).mean()
print(jz)
create_dt
2016-11-30 NaN
2016-11-30 NaN
2016-11-30 NaN
2016-11-30 NaN
2016-12-02 NaN
...
2016-12-31 5.016
2016-12-31 4.185
2016-12-31 3.500
2016-12-31 2.802
2016-12-31 2.066
Name: sku_cost_prc, Length: 756, dtype: float64
自律的顶端就是享受孤独!这一年里,失去,释怀,成长,完结一半!!
点赞,你的认可是我创作的
动力
!
收藏,你的青睐是我努力的方向
!
评论,你的意见是我进步的财富
!
关注,你的喜欢是我长久的坚持
!
欢迎关注微信公众号【程序人生6】,一起探讨学习哦!!!