when I try to run the following code, I get an error
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
from statsmodels.tsa.stattools import adfuller
from statsmodels.tsa.seasonal import seasonal_decompose
import time
from tqdm import tqdm
from scipy import stats
from sklearn.metrics import mean_squared_error
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.feature_selection import RFE
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.metrics import f1_score
from sklearn.metrics import roc_auc_score
from sklearn.metrics import roc_curve, auc
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
from xgboost import XGBClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
df = pd.read_csv("sensor.csv")
print('here')
df.head()
# Find Duplicate Values
# Results will be the list of duplicate values
# If no duplicate values, nothing will list.
df[df['timestamp'].duplicated(keep=False)]
df.isnull().sum()
df['machine_status'].value_counts()
# Convert timestamp column into data type into datetime
df['timestamp'] = pd.to_datetime(df['timestamp'])
# Create a Series
time_period = pd.Series([])
# Assign values to series
for i in tqdm(range(df.shape[0])):
if (df["timestamp"][i].hour >= 4) and (df[timestamp][i].hour < 10):
time_period[i]="Morning"
elif (df["timestamp"][i].hour >= 10) and (df[timestamp][i].hour < 16):
time_period[i]="Noon"
elif (df["timestamp"][i].hour >= 16) and (df[timestamp][i].hour < 22):
time_period[i]="Evening"
else:
time_period[i]="Night"
# Insert new column time period
df.Insert(2, 'time_period', time_period) I get an error. The error is:
Larz60+ write Jun-11-2022, 02:32 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
