简体   繁体   中英

Write dataframe to csv

I have a problem to save the printed datum. In below picture, all of data was calculated, and I tried to save the results to CSV file. However, only the last line was saved. In this case, what shall I do? Do I have to use the loop method? Could give me some hints or solutions?

r = 2 
while r < 5:
   r = r+1
   tan = [] 
   for compo in theta:
       tan.append(math.tan(compo))

   disp =[]
   for i in df.loc[r]:
       disp.append(i)

   Vy = []
   for a in tan:
        for b in disp:
            if tan.index(a) == disp.index(b):
                Vy.append(float(a)*float(b))

   Final = []
   for neg in Vy:
       Final.append(abs(neg))

   df3 = pd.DataFrame([Final])
   print(df3)

How are there multiple lines? Perhaps this is due to your console having line-wrapping but not your text editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM