Python for Moon. Question from Python for Moon!

Asked 2 years ago, Updated 2 years ago, 97 views

I'm going to turn the for statement to Cf1, Cf2, Cf3, and Cf4 below!

It's blocked from the beginning. Help me!

Cf1 = pd.read_csv("1Y.csv")

Cf1 = Cf1.dropna()

Cf1.isna().sum()


xy1 = np.array(Cf1, dtype=np.float32)

x1 = xy1[:, 0:-1]


x_data1 = normalize(x1)

y_data1 = xy1[:, [-1]]

+) The idea in my head is

for i in range(4):

    Cf[i] = pd.read_csv("iY.csv") 

In this way, the variable does not have i, and the file reading also works

python for

2022-09-22 13:31

1 Answers

Try it as below.

for f in (pd.read_csv("{}Y.csv".format(i)) for i in range(1, 5)):
    f.dropna()
    ...
    ...


2022-09-22 13:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.