Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

python - 如何从Colab中从上传的csv提取的数据框中的前一行减去前一行?(How to subtract row from previous row in dataframe extracted from uploaded csv in Colab?)

After uploading csv file from local drive and wrapping it with stringIO,I used pd.read_csv to convert it into dataframe.

(从本地驱动器上传csv文件并用stringIO包装后,我使用pd.read_csv将其转换为数据帧。)

But unable to subtract a row from previous row.

(但是无法从上一行减去一行。)

It shows TypeError: unsupported operand type(s) for -: 'str' and 'str'

(它显示TypeError:-的不支持的操作数类型:“ str”和“ str”)

import pandas as pd
from google.colab import files
uploaded1= files.upload()
import io
df1= pd.read_csv(io.StringIO(uploaded1['sbi.csv'].decode('utf-8')))
df1.diff()
TypeError: unsupported operand type(s) for -: 'str' and 'str'
  ask by Animal translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...