1
I am trying to import from an external file some data to be able to generate a graph and such, but every time of this error, follows my code:
They may also say bugs you found in my code that can be improved, I’m starting in python yet and would like to learn too
import matplotlib.pyplot as plt
class poisson():
def __init__(self):
stopTimes = []
times = []
self.stopTime = stopTimes
self.times = times
def importPoisson(enterArchive):
database = open('import/'+enterArchive+'.csv', 'r')
for count in database:
count = count.strip()
stop,time = count.split(',')
poisson.stopTimes.append(stop)
poisson.times.append(time)
return poisson.stopTimes, poisson.times
def plotGraphic(self):
plt.title("Poisson")
plt.step(poisson.times, poisson.stopTimes, label="Paradas de carros")
plt.legend()
plt.xlabel("Tempo")
plt.ylabel("Paradas")
plt.show()
pos = poisson()
pos.importPoisson("eventEntrance")
pos.plotGraphic()
Follow a print of the data I want to enter
Parameter is missing
self
in theimportPoisson
– Isac
Gee, I realize now, thank you very much, but you’re giving me another error Attributeerror: type Object 'Poisson' has no attribute 'stopTimes', can you tell me what it is?
– DanielB
This is because the class you have does not have this method. It is advisable to review the code you have calmly, and realize exactly what each thing does
– Isac
How strange, I did the same thing with another method following the same steps and it worked, now I really did not understand
– DanielB
I understood, VALEU ISAC, TAVA MISSING 1 LETTER KKKKK, I had created stopTimes and was calling so stopTime kkk
– DanielB