0
Hello! I am trying to generate a function that reads imported data from a "csv" file and converts it to an array. The data of one column is integer, and of the other column is an intercalation of strings and integer, thus:
What I’ve written so far is: "
def sundata(arquivo):
import pandas as pd
import numpy as np
s_data = pd.read_csv(arquivo, delimiter = ';')
par_dat = []
for i,j in zip( par_dat['Az'] , par_dat['data'] ):
par_data = np.append(par_dat,[[i],[j]])
par_dat= np.reshape(par_dat,(len(data['Az']),2))
return par_dat
" What I get is the following error: "List indices must be integers or Slices, not strings". If anyone can help I would be very grateful :)
Why would you do that? Pandas wouldn’t be enough to help you do any operation with this data? Is there any restriction?
– Tmilitino
I need to use a function within a library called Pymag. In the function, I enter a series of data and it returns an integer value. If I had little data I could make a list or insert one by one. But it turns out that I have more than 1000 data and make each of them unfeasible. So I’m trying to create a way to insert them all at once into the function and then create a txt of the answer of each data.So I’m trying to import the data from csv and turn it into an array"...
– Ualisson Donardelli Bellon
accurate preserves the name of columns?
– Tmilitino
No, there’s no need!
– Ualisson Donardelli Bellon