【发布时间】:2019-11-13 15:32:35
【问题描述】:
我的理解是,在“=”操作数的情况下,信息从右向左流动。即 a=b 意味着 b 的值被转移到 a。如果我之后更改 a,它不应该影响 b 的值。但在下面的代码中,它正在发生。谁能告诉我为什么会这样?
df_main=fivminohlc
result=df_main.dtypes
print(result)
result=fivminohlc.dtypes
print(result)
O float64
H float64
L float64
C float64
V int64
dtype: object
O float64
H float64
L float64
C float64
V int64
dtype: object
df_main['Y1']=(df_main['C']-df_main['O'])/df_main['O'] # I have not touched fivminohlc
df_main['Y'] = np.where((df_main.Y1 > .001), 2, 1)
df_main['Y'] = np.where((df_main.Y1 < -.001), 0, 1)
result=df_main.dtypes
print(result)
result=fivminohlc.dtypes
print(result)
O float64
H float64
L float64
C float64
V int64
Y1 float64
Y int32
dtype: object
O float64
H float64
L float64
C float64
V int64
Y1 float64
Y int32
dtype: object
fivminohlc中怎么会显示Y和Y1
【问题讨论】:
-
制作deep copy时,您仍在编辑原始元素。
标签: python dataframe math return-value assign