Reputation: 995
This piece of code is working at one place but throwing error at another place not sure why i am encountering this below error:
plt.suptitle plt.suptitle(dataset.columns[i] + ' (xyz)', fontsize=10)
TypeError: can only concatenate tuple (not "str") to tuple
import numpy as np
import matplotlib.pyplot as plt
dataset = df
dfsize = dataset[df.columns[0]].size
x = []
for i in range(dfsize):
x.append(i)
dataset.shape
# dataset.dropna(inplace=True)
dataset.columns.values
var = ""
for i in range(dataset.shape[1]): ## 1 is for column, dataset.shape[1] calculate length of col
y = dataset[dataset.columns[i]].values
y = y.astype(float)
y = y.reshape(-1, 1)
y.shape
from sklearn.impute import SimpleImputer
missingvalues = SimpleImputer(missing_values=np.nan, strategy='mean', verbose=0)
missingvalues = missingvalues.fit(y)
y = missingvalues.transform(y[:, :])
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.compose import ColumnTransformer
labelencoder_x = LabelEncoder()
x = labelencoder_x.fit_transform(x)
from scipy.interpolate import *
p1 = np.polyfit(x, y, 1)
# from matplotlib.pyplot import *
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.figure()
plt.xticks(x, months, rotation=25,fontsize=8)
plt.suptitle(dataset.columns[i] + ' (xyz)', fontsize=10)
i think my issue is coming due to wrong dataframe:
working dataframe is:
in month
AM April NaN
February 100.0
January 99.0
wrong dataframe:
Verify the countDays
Assign month
AD April 48.86
February 4.76
January 14.70
Upvotes: 1
Views: 230
Reputation: 9484
Change:
plt.suptitle(dataset.columns[i] + ' (xyz)', fontsize=10)
To:
plt.suptitle(dataset.columns[i] + ('xyz',), fontsize=10)
Upvotes: 1
Reputation: 995
i had to do some unprofessional way to solve this issue and by doing the following way it solved. However, i would like to know if there is some good way to do this.
I tried removing the first row but datafarme was so bad that i do not know why first row was not getting deleted and it was having some weired behaviour.
dff3=dff.groupby(['Assign','month'])[['Verify the countDays']].mean().round(decimals=2)
dff4=dff.groupby(['Assign','month'])[['Verify the countDays']].mean().round(decimals=2)
dff5=(dff3['Verify the countDays']/dff3['Verify the countDays'])+(dff3['Verify the countDays'])
Upvotes: 0