微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

当我使用漂亮的表格打印表格时,我没有进入单列

如何解决当我使用漂亮的表格打印表格时,我没有进入单列

有人可以帮助我吗?每次打印时,我无法在单列中打印它在不同列中的打印

from prettytable import prettytable
import pandas as pd
for filename in os.listdir('Nse_Histrocial_Data'):
#print(filename)
symbol = filename.split(".")[0]
#print(symbol)
df = pandas.read_csv('Nse_Histrocial_Data/{}'.format(filename))
if df.empty:
    continue

df['20sma'] = df['Close'].rolling(window=20).mean()
df['stddev'] = df['Close'].rolling(window=20).std()
df['lower_band'] = df['20sma'] - (2 * df['stddev'])
df['upper_band'] = df['20sma'] + (2 * df['stddev'])

df['TR'] = abs(df['High'] - df['Low'])
df['ATR'] = df['TR'].rolling(window=20).mean()

df['lower_keltner'] = df['20sma'] - (df['ATR'] * 1.5)
df['upper_keltner'] = df['20sma'] + (df['ATR'] * 1.5)

def in_squeeze(df):
    return df['lower_band'] > df['lower_keltner'] and df['upper_band'] < df['upper_keltner']

df['squeeze_on'] = df.apply(in_squeeze,axis=1)

if df.iloc[-2]['squeeze_on'] and not df.iloc[-1]['squeeze_on']:
    data = ("{}".format(symbol))
    myTable = prettytable(['Stock'])
    myTable.add_row([data])
    print(myTable)

图片https://i.stack.imgur.com/Evnr4.png

解决方法

是的,我也在努力寻找可以帮助我运行网站的正确代码,您可以在此处查看我当前代码的详细信息。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。