查找重复并分别翻转它们

发布于 2025-02-11 04:29:49 字数 1525 浏览 1 评论 0原文

df[0] = [0.0000000,0.0082707,0.0132000, 0.0255597, 0.0503554, 0.0751941, 0.1000570, 0.1498328, 0.1996558, 0.2495240, 0.2994312, 0.3993490, 0.4993711, 0.5994664, 0.6996058, 0.7997553, 0.8998927, 0.9499514, 1.0000000, 0.0000000, 0.006114 , 0.0062188, 0.0087532, 0.0138088, 0.0264052, 0.0515127, 0.0765762, 0.1016176, 0.1516652, 0.2016828, 0.2516733, 0.3016387, 0.4015163, 0.5013438, 0.6011363, 0.7008976, 0.8006328, 0.9003380, 0.9501740, 1.0000000]

df[1] = [0.00000,0.0233088,0.0298517,0.0425630,0.0603942,0.0739301,0.0850687,0.1023515,0.1149395,0.1149395,0.1230325,0.1230325,0.1272298,0.1272298,0.12253360,3333333533335333533333353335333335333353335333335333355 0445423、0.0207728、0.0098870、0.0000000、0.0000000,-.0208973,-.0210669,-.0210669, -.0247377, -.0307807, -.0416431, -.0548774, -.0637165, -.0703581, -.0801452, -.0869356, -.0910290, -.0926252, -.0905235, -.0834273, -. 0728351,-.0591463,-.0428603,-.0235778,-.0122883,0.0000000]

您可以使python代码在df [0] df [0]和Lets中检测到一定数量的零数在此示例中说,如果它检测到三个或更多零在中间翻转阵列?因此,它看起来像df [0] = [0.00000,0.0082707,0.0132000,0.0255597,0.0503554,0.0751941,0.1000570,0.1498328,0.1498328 994664,0.6996058,0.7997553,0.8998927,0.9499514,1.0000000 , 1.0000000, 0.950174, 0.900338, 0.8006328, 0.7008976, 0.6011363, 0.5013438, 0.4015163, 0.3016387, 0.2516733, 0.2016828, 0.1516652, 0.1016176, 0.0765762, 0.0515127, 0.0264052, 0.0138088, 0.0087532 ,0.0062188, 0.006114, 0.0000000] 以及Flip df [1]尊重df [0]

df[0] = [0.0000000,0.0082707,0.0132000, 0.0255597, 0.0503554, 0.0751941, 0.1000570, 0.1498328, 0.1996558, 0.2495240, 0.2994312, 0.3993490, 0.4993711, 0.5994664, 0.6996058, 0.7997553, 0.8998927, 0.9499514, 1.0000000, 0.0000000, 0.006114, 0.0062188, 0.0087532, 0.0138088, 0.0264052, 0.0515127, 0.0765762, 0.1016176, 0.1516652, 0.2016828, 0.2516733, 0.3016387, 0.4015163, 0.5013438, 0.6011363, 0.7008976, 0.8006328, 0.9003380, 0.9501740, 1.0000000]

df[1] = [0.0000000, 0.0233088, 0.0298517, 0.0425630, 0.0603942, 0.0739301, 0.0850687, 0.1023515, 0.1149395, 0.1230325, 0.1272298, 0.1253360, 0.1130538, 0.0934796, 0.0695104, 0.0445423, 0.0207728, 0.0098870, 0.0000000, 0.0000000, -.0208973, -.0210669, -.0247377, -.0307807, -.0416431, -.0548774, -.0637165, -.0703581, -.0801452, -.0869356, -.0910290, -.0926252, -.0905235, -.0834273, -.0728351, -.0591463, -.0428603, -.0235778, -.0122883, 0.0000000]

Can you make a python code detect a certain amount of zeros in df[0] and lets say for this example if it detects three or more zeros flip the array in the middle? so it looks like df[0] = [0.0000000,0.0082707,0.0132000, 0.0255597, 0.0503554, 0.0751941, 0.1000570, 0.1498328, 0.1996558, 0.2495240, 0.2994312, 0.3993490, 0.4993711, 0.5994664, 0.6996058, 0.7997553, 0.8998927, 0.9499514, 1.0000000, 1.0000000, 0.950174, 0.900338, 0.8006328, 0.7008976, 0.6011363, 0.5013438, 0.4015163, 0.3016387, 0.2516733, 0.2016828, 0.1516652, 0.1016176, 0.0765762, 0.0515127, 0.0264052, 0.0138088, 0.0087532 ,0.0062188, 0.006114, 0.0000000]
and also flip df[1] respect to df[0]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦行七里 2025-02-18 04:29:49
discont = np.diff(df[0]).argmin()
x1 = df[0][:discont+1]
x1 = np.array(x1)

y1 = df[1][:discont+1]

x2 = df[0][discont+1:]
x2 = np.array(x2)

y2 = df[1][discont+1:]
y2 = np.array(y2)

x_flip = np.flip(x2)
y_flip = np.flip(y2)

x = np.concatenate((x1,x_flip))
y = np.concatenate((y1,y_flip))
discont = np.diff(df[0]).argmin()
x1 = df[0][:discont+1]
x1 = np.array(x1)

y1 = df[1][:discont+1]

x2 = df[0][discont+1:]
x2 = np.array(x2)

y2 = df[1][discont+1:]
y2 = np.array(y2)

x_flip = np.flip(x2)
y_flip = np.flip(y2)

x = np.concatenate((x1,x_flip))
y = np.concatenate((y1,y_flip))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文