Hello I am entered to update a code that used pandas 0.23.4 the line data ['dt'] = pd.DatetimeIndex (data.ix [:, 0]) brings me errors after upgrading pandas and python. According to research, this function (pandas.dataframe.ix) has been removed. Which method can be used to replace it? Basically what the code does, it does mean values per hour, which it writes to a new folder
import pandas as pd
from msvcrt import getch
from os import listdir
#reading file and user input
file_name = [filename for filename in listdir() if (".csv" or ".txt") in filename]
if not file_name:
print("\nThere are no .csv files in folder")
print(listdir())
else:
for file in file_name:
print("\nParsing {}".format(file))
typ = file[-4:] #get extension of file
if (typ == ".csv"):
data = pd.read_csv(file, sep=';', encoding='utf-8', skiprows = 2)
#subcase for different type of separators
if len(data.columns) == 1:
data = pd.read_csv(file, sep=',', encoding='utf-8', skiprows = 2)
else:
data = pd.read_csv(file, sep=';', encoding='utf-16', skiprows = 2)
if len(data.columns) == 1:
data = pd.read_csv(file, sep=',', encoding='utf-16', skiprows = 2)
data['Valeur'] = data['Valeur'] / 1000
data['dt'] = pd.DatetimeIndex(data.ix[:, 0])
data = data.set_index(data['dt']).tz_localize("UTC").tz_convert("Europe/Paris")
data['Valeur'].resample('1h').mean().to_csv("output//{}_0.csv".format(file[:-4].split(".")[0]))
print("\nPress any key (other than ALT) to exit")
getch()