Вы можете сделать флаг перед возвратом
public static void cat(File file) {
boolean readAll = false;
try (RandomAccessFile input = new RandomAccessFile(file, "r")){
String line = null;
while ((line = input.readLine()) != null) {
System.out.println(line);
}
readAll = true;
return;
} catch(FileNotFoundException a){
;//do something to recover from this exception.
}catch(IOException b){
;//distinguish between close and readLine exception.
if (readAll) ...
}
}
Сначала создайте DatetimeIndex
с помощью to_datetime
, а затем установите значения с помощью DataFrame.loc
:
df.index = pd.to_datetime(df.index)
df.loc['1/6/2019':'1/9/2019', 'Column 1'] = 0
print (df)
Column 1 Column 2 Column 3
Channel
2018-12-30 638 4472 487
2018-12-31 868 6985 540
2019-01-01 755 4401 829
2019-01-02 1655 9484 1145
2019-01-03 2002 14212 1158
2019-01-04 1633 9575 1098
2019-01-05 1026 5575 941
2019-01-06 0 4963 1007
2019-01-07 0 10685 1246
2019-01-08 0 9932 1151
2019-01-09 0 1031 1087
2019-01-10 2168 1005 1074
2019-01-11 2052 9371 909
2019-01-12 1223 5953 895
2019-01-13 1268 4809 827