0

I am a beginner in python and I'm trying to graph some data from a file. The code is the following:

import matplotlib.pyplot as plt
import pandas as pd
from scipy.signal import find_peaks

import os 

dataFrame = pd.read_csv('soporte.txt', sep='\t',skiprows=1, encoding = 'utf-8-sig')


x = dataFrame['Wavelength nm.']
y = dataFrame['Abs.']


indices, _ = find_peaks(y, threshold=1)

plt.plot(x, y)

plt.show()

And I get the following error:

ValueError: could not convert string to float: '-0,04008'

I'll show you a piece of the file I am trying to work with:

"soporte.spc - RawData"
"Wavelength nm."    "Abs."
180,0   -0,04008
181,0   -0,00084
182,0   -0,00746
183,0   0,00854
184,0   -0,01525
185,0   -0,00354

Thank you very much!!!

L

1 Answer 1

3

Use the decimal=',' option in pandas, i.e.,

dataFrame = pd.read_csv('soporte.txt', sep='\t',skiprows=1, encoding = 'utf-8-sig', decimal=',')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.