Related
I'm trying to run 3 optimization with for loop and store the results in one dataframe.
After each optimization (element of the for loop), I append lists of results and being able to get all the reults in one list. However, when I try to convert the list to dataframe, I get one row for each of the optimization and multiple values in each cell corresponding to the variable name and the optimization number like this:
Date = []
results = []
for idx, df in enumerate([df0,df1,df2]):
model = ConcreteModel()
model.T = Set(initialize=df.hour.tolist(), ordered=True)
...
# Solve model
solver = SolverFactory('glpk')
solver.solve(model)
Date = list(df['Date'])
results.append([Date, model.Ein.get_values().values(), model.Eout.get_values().values(),
model.Z.get_values().values(), model.NES.get_values().values(),
model.L.get_values().values()])
df_results = pd.DataFrame(results)
df_results.rename(columns = {0: 'Date', 1: 'Ein', 2:'Eout', 3:'Z', 4:'NES', 5:'L'}, inplace = True)
df_results
## The output of the df is:
Date Ein
0 [2019-01-01, 2019-01-01, 2019-01-01, 2019-01-0... (0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, ... (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... (0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 4.0, 5.0, 5.0, ... (0.0, 0.0, -100.0, -100.0, -100.0, 0.0, -100.0... (16231.0, 16051.0, 15806.0, 15581.0, 15610.0, ...
1 [2019-01-16, 2019-01-16, 2019-01-16, 2019-01-1... (0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, ... (0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, ... (0.0, 1.0, 1.0, 1.0, 1.0, 0.5, 1.5, 2.5, 3.5, ... (0.0, -100.0, 0.0, 0.0, 0.0, 50.0, -100.0, -10... (17643.0, 18654.0, 20462.0, 20448.0, 20305.0, ...
2 [2019-01-31, 2019-01-31, 2019-01-31, 2019-01-3... (0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, ... (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, ... (0.0, 0.0, 1.0, 1.0, 2.0, 3.0, 4.0, 3.0, 3.0, ... (0.0, 0.0, -100.0, 0.0, -100.0, -100.0, -100.0... (22155.0, 22184.0, 21510.0, 21193.0, 20884.0, ...
#The output of the list named results is:
[[['2019-01-01',
'2019-01-01',
'2019-01-01',
...
'2019-01-15',
'2019-01-15',
'2019-01-15',
'2019-01-15',
'2019-01-15',
'2019-01-15',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16'],
dict_values([0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
...
-1.11022302462516e-16, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.11022302462516e-16, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.166666666666667, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.333333333333333, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.666666666666667, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]),
dict_values([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0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.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.166666666666667, 0.0, 0.0, 0.0, 0.666666666666667, 0.333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625, 0.001953125, 0.0009765625, 0.00048828125, 0.0]),
dict_values([0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 4.0, 3.0, 2.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 4.5, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 3.0, 3.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 4.0, 5.0, 5.0, 5.0, 4.0, 3.0, 3.0, 3.0,
...
0.142857142857143, 0.142857142857143, 1.0, 2.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 4.0, 5.0, 5.0, 5.0, 4.0, 3.0, 3.0, 3.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.33333333333333, 1.33333333333333, 0.666666666666667, 0.666666666666667, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625, 0.001953125, 0.0009765625, 0.00048828125, 0.00048828125]),
[['2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
'2019-01-16',
...
Is it because each result in the for loop has de different dictionary? How could my results in this form:
Date Ein Eout Z NES L
0 2019-01-01 1.0 0.0 1.0 -100.0 16231.0
1 2019-01-01 1.0 1.0 0.0 100.0 16051.0,
...
You're constantly appending to results creating a list of lists of the wrong dimension. I hope this solution works for you -
df_results = pd.DataFrame(zip(Date, model.Ein.get_values().values(), model.Eout.get_values().values(),
model.Z.get_values().values(), model.NES.get_values().values(),
model.L.get_values().values()))
Let me know if it doesn't.
Assume that I have the following dictionary:
scenario_summary = {'Day1': {'22459-22585': 0.0, '22585-22711': 0.0, '22711-22837': 0.0, '22837-22963': 0.0, '22963-23089': 0.0, '23089-23215': 0.0, '23215-23341': 0.0, '23341-23467': 0.0, '23467-23593': 0.0, '23593-23719': 0.0, '23719-23845': 0.0, '23845-23971': 0.0, '23971-24097': 0.0, '24097-24223': 0.0, '24223-24349': 0.0, '24349-24475': 0.0, '24475-24601': 0.0, '24601-24727': 0.0, '24727-24853': 0.0, '24853-24979': 0.0, '24979-25105': 0.0, '25105-25231': 0.0, '25231-25357': 0.0, '25357-25483': 0.0, '25483-25609': 0.0, '25609-25735': 0.0, '25735-25861': 0.0, '25861-25987': 0.0, '25987-26113': 1.0, '26113-26239': 1.0, '26239-26365': 0.0, '26365-26491': 2.0, '26491-26617': 5.0, '26617-26743': 5.0, '26743-26869': 5.0, '26869-26995': 12.0, '26995-27121': 19.0, '27121-27247': 7.000000000000001, '27247-27373': 11.0, '27373-27499': 15.0, '27499-27625': 7.000000000000001, '27625-27751': 4.0, '27751-27877': 4.0, '27877-28003': 2.0, '28003-28129': 0.0, '28129-28255': 0.0, '28255-28381': 0.0, '28381-28507': 0.0, '28507-28633': 0.0, '28633-28759': 0.0, '28759-28885': 0.0, '28885-29011': 0.0, '29011-29137': 0.0, '29137-29263': 0.0, '29263-29389': 0.0, '29389-29515': 0.0, '29515-29641': 0.0, '29641-29767': 0.0, '29767-29893': 0.0, '29893-30019': 0.0, '30019-30145': 0.0, '30145-30271': 0.0, '30271-30397': 0.0, '30397-30523': 0.0, '30523-30649': 0.0, '30649-30775': 0.0, '30775-30901': 0.0, '30901-31027': 0.0, '31027-31153': 0.0, '31153-31279': 0.0, '31279-31405': 0.0, '31405-31531': 0.0, '31531-31657': 0.0, '31657-31783': 0.0, '31783-31909': 0.0, '31909-32035': 0.0, '32035-32161': 0.0, '32161-32287': 0.0, '32287-32413': 0.0, '32413-32539': 0.0, '32539-32665': 0.0, '32665-32791': 0.0, '32791-32917': 0.0, '32917-33043': 0.0, '33043-33169': 0.0, '33169-33295': 0.0, '33295-33421': 0.0, '33421-33547': 0.0, '33547-33673': 0.0, '33673-33799': 0.0, '33799-33925': 0.0, '33925-34051': 0.0, '34051-34177': 0.0, '34177-34303': 0.0, '34303-34429': 0.0, '34429-34555': 0.0, '34555-34681': 0.0, '34681-34807': 0.0}}
As you can see, the dictionary consists of a range of values in string and their frequency. I would like to plot this as a histogram, but I don't know how I would be able to transform the string into a form that pandas or plotly would understand. What would your approach be? Or is there an easier way to do it, instead of hardcoding things? Or, would another module be easier option in doing so?
Thanks!
Since the bins (ranges) are already defined and their counts are already aggregated at an initial level, maybe it can help if you build something that overlays a histogram (distribution) on the top of the existing bin ranges:
import matplotlib
%matplotlib inline
def plot_hist(bins,input_dict):
df1 = pd.DataFrame(input_dict).reset_index()
df1['min'] = df1['index'].apply(lambda x:x.split('-')[0]).astype(int)
df1['max'] = df1['index'].apply(lambda x:x.split('-')[1]).astype(int)
df1['group'] = pd.cut(df1['max'],bins,labels=False)
df2 = df1.groupby('group' [['Day1','min','max']].agg({'min':'min','max':'max','Day1':'sum'}).reset_index()
df2['range_new'] = df2['min'].astype(str) + str('-') + df2['max'].astype(str)
df2.plot(x='range_new',y='Day1',kind='bar')
...and call the function by choosing bins lesser than the length of the dictionary - or the first level of 98 bins that are already there, like, say if you want a distribution of 20 groups aggregate:
plot_hist(20,scenario_summary)
Result Image :
hope it helps...
A histogram is basically a simple bar chart, where each bar represents a bin (usually in the form of a range) and a frequency of the elements that fall into that bin.
This is exactly the data that you already have. So instead of computing values for a histogram (as it would be done with plt.hist), you can simply pass your data to plt.bar, as it is. The result would then be this:
The code with your data, as a MCVE :
import matplotlib.pyplot as plt
scenario_summary = { 'Day1': {
'22459-22585': 0.0, '22585-22711': 0.0, '22711-22837': 0.0,
'22837-22963': 0.0, '22963-23089': 0.0, '23089-23215': 0.0,
'23215-23341': 0.0, '23341-23467': 0.0, '23467-23593': 0.0,
'23593-23719': 0.0, '23719-23845': 0.0, '23845-23971': 0.0,
'23971-24097': 0.0, '24097-24223': 0.0, '24223-24349': 0.0,
'24349-24475': 0.0, '24475-24601': 0.0, '24601-24727': 0.0,
'24727-24853': 0.0, '24853-24979': 0.0, '24979-25105': 0.0,
'25105-25231': 0.0, '25231-25357': 0.0, '25357-25483': 0.0,
'25483-25609': 0.0, '25609-25735': 0.0, '25735-25861': 0.0,
'25861-25987': 0.0, '25987-26113': 1.0, '26113-26239': 1.0,
'26239-26365': 0.0, '26365-26491': 2.0, '26491-26617': 5.0,
'26617-26743': 5.0, '26743-26869': 5.0, '26869-26995': 12.0,
'26995-27121': 19.0, '27121-27247': 7.0, '27247-27373': 11.0,
'27373-27499': 15.0, '27499-27625': 7.0, '27625-27751': 4.0,
'27751-27877': 4.0, '27877-28003': 2.0, '28003-28129': 0.0,
'28129-28255': 0.0, '28255-28381': 0.0, '28381-28507': 0.0,
'28507-28633': 0.0, '28633-28759': 0.0, '28759-28885': 0.0,
'28885-29011': 0.0, '29011-29137': 0.0, '29137-29263': 0.0,
'29263-29389': 0.0, '29389-29515': 0.0, '29515-29641': 0.0,
'29641-29767': 0.0, '29767-29893': 0.0, '29893-30019': 0.0,
'30019-30145': 0.0, '30145-30271': 0.0, '30271-30397': 0.0,
'30397-30523': 0.0, '30523-30649': 0.0, '30649-30775': 0.0,
'30775-30901': 0.0, '30901-31027': 0.0, '31027-31153': 0.0,
'31153-31279': 0.0, '31279-31405': 0.0, '31405-31531': 0.0,
'31531-31657': 0.0, '31657-31783': 0.0, '31783-31909': 0.0,
'31909-32035': 0.0, '32035-32161': 0.0, '32161-32287': 0.0,
'32287-32413': 0.0, '32413-32539': 0.0, '32539-32665': 0.0,
'32665-32791': 0.0, '32791-32917': 0.0, '32917-33043': 0.0,
'33043-33169': 0.0, '33169-33295': 0.0, '33295-33421': 0.0,
'33421-33547': 0.0, '33547-33673': 0.0, '33673-33799': 0.0,
'33799-33925': 0.0, '33925-34051': 0.0, '34051-34177': 0.0,
'34177-34303': 0.0, '34303-34429': 0.0, '34429-34555': 0.0,
'34555-34681': 0.0, '34681-34807': 0.0}}
data = scenario_summary['Day1']
x = range(len(data))
y = list(data.values())
plt.figure(figsize=(16, 9))
plt.bar(x, y)
plt.subplots_adjust(bottom=0.2)
plt.xticks(x, data.keys(), rotation='vertical')
plt.show()
You can use pandas module to convert dictionary data into data frame:
import pandas as pd
import matplotlib.pyplot as plt
scenario_summary = {'Day1': {'22459-22585': 0.0, '22585-22711': 0.0, '22711-22837': 0.0,
'22837-22963': 0.0, '22963-23089': 0.0, '23089-23215': 0.0,
'23215-23341': 0.0, '23341-23467': 0.0, '23467-23593': 0.0,
'23593-23719': 0.0, '23719-23845': 0.0, '23845-23971': 0.0,
'23971-24097': 0.0, '24097-24223': 0.0, '24223-24349': 0.0,
'24349-24475': 0.0, '24475-24601': 0.0, '24601-24727': 0.0,
'24727-24853': 0.0, '24853-24979': 0.0, '24979-25105': 0.0,
'25105-25231': 0.0, '25231-25357': 0.0, '25357-25483': 0.0,
'25483-25609': 0.0, '25609-25735': 0.0, '25735-25861': 0.0,
'25861-25987': 0.0, '25987-26113': 1.0, '26113-26239': 1.0,
'26239-26365': 0.0, '26365-26491': 2.0, '26491-26617': 5.0,
'26617-26743': 5.0, '26743-26869': 5.0, '26869-26995': 12.0,
'26995-27121': 19.0, '27121-27247': 7.000000000000001, '27247-27373': 11.0,
'27373-27499': 15.0, '27499-27625': 7.000000000000001, '27625-27751': 4.0,
'27751-27877': 4.0, '27877-28003': 2.0, '28003-28129': 0.0,
'28129-28255': 0.0, '28255-28381': 0.0, '28381-28507': 0.0,
'28507-28633': 0.0, '28633-28759': 0.0, '28759-28885': 0.0,
'28885-29011': 0.0, '29011-29137': 0.0, '29137-29263': 0.0,
'29263-29389': 0.0, '29389-29515': 0.0, '29515-29641': 0.0,
'29641-29767': 0.0, '29767-29893': 0.0, '29893-30019': 0.0,
'30019-30145': 0.0, '30145-30271': 0.0, '30271-30397': 0.0,
'30397-30523': 0.0, '30523-30649': 0.0, '30649-30775': 0.0,
'30775-30901': 0.0, '30901-31027': 0.0, '31027-31153': 0.0,
'31153-31279': 0.0, '31279-31405': 0.0, '31405-31531': 0.0,
'31531-31657': 0.0, '31657-31783': 0.0, '31783-31909': 0.0,
'31909-32035': 0.0, '32035-32161': 0.0, '32161-32287': 0.0,
'32287-32413': 0.0, '32413-32539': 0.0, '32539-32665': 0.0,
'32665-32791': 0.0, '32791-32917': 0.0, '32917-33043': 0.0,
'33043-33169': 0.0, '33169-33295': 0.0, '33295-33421': 0.0,
'33421-33547': 0.0, '33547-33673': 0.0, '33673-33799': 0.0,
'33799-33925': 0.0, '33925-34051': 0.0, '34051-34177': 0.0,
'34177-34303': 0.0, '34303-34429': 0.0, '34429-34555': 0.0,
'34555-34681': 0.0, '34681-34807': 0.0}}
# convert to data frame
data_frame = pd.DataFrame.from_dict(scenario_summary)
# plot data
plt.hist(data_frame['Day1'], density=1, bins=20)
plt.show()
I can not transpose my text data the right way and replace the ',' with ' ' generating a new text file.
My text is:
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0011, 0.00066, 0.00137, 0.00079, 0.00071, 0.00141, 0.0, 0.00182, 0.00151, 0.00077,
0.00166, 0.00242, 0.0061, 0.01112, 0.0, 0.01417, 0.00414, 0.00228, 0.0027, 0.0,
0.0, 0.0, 0.01248, 0.0, 0.0, 0.06371, 0.00448, 0.0, 0.01182, 0.0,
0.01938, 0.06195, 0.00791, 0.0, 0.05479, 0.00646, 0.05939, 0.02536, 0.06581, 0.00146,
0.0, 0.10148, 0.00858, 0.05245, 0.03534, 0.02738, 0.0, 0.01521, 0.02567, 0.01389,
0.0, 0.01177, 0.11606, 0.41767, 0.17797, 0.02097, 0.04637, 0.0, 0.0, 0.01696,
0.03828, 0.03649, 0.01519, 0.0465, 0.04523, 0.0, 0.11382, 0.03256, 0.239, 0.06641,
0.00726, 0.0, 0.02342, 0.03302, 0.11531, 0.0, 0.33871, 0.21537, 0.0, 0.19708,
1.08416, 0.03333, 0.01763, 0.25371, 0.01275, 0.31206, 0.0, 0.07271, 0.06306, 0.05016,
0.00482, 0.11395, 0.0, 0.14741, 0.04568, 0.0, 0.0, 0.0, 0.16177, 0.00628,
0.05526, 0.07857, 0.41543, 0.0172, 0.0, 0.0, 0.0, 0.28001, 0.01096, 0.0,
0.0, 0.14767, 0.0, 0.88451, 0.11258, 0.57063, 0.23525, 0.19962, 0.10215, 0.12147,
0.15307, 0.06756, 0.20032, 0.0, 0.38074, 0.0, 0.30569, 0.0, 0.14491, 0.01522,
0.15175, 0.0, 0.47177, 0.09829, 0.13909, 0.21286, 0.0, 0.38484, 0.06639, 0.0,
0.25202, 0.21179, 0.82245, 0.4142, 0.0, 0.08601, 0.56517, 0.0, 0.59679, 0.23728,
0.04749, 0.29558, 0.24965, 0.0, 0.0, 0.22227, 0.72755, 0.62913, 0.0, 0.0,
0.0, 0.19146, 0.0, 0.0, 0.0, 0.2144, 0.77099, 0.0, 0.37493, 0.89662,
0.47225, 0.43947, 0.12473, 0.35669, 0.10165, 0.45582, 0.22459, 0.29898, 0.0, 0.56291,
0.96687, 0.0, 0.3302, 0.86844, 0.06221, 0.77419, 0.17999, 0.65999, 0.2328, 0.0,
0.16307, 0.76734, 0.52557, 0.26596, 0.0, 0.0, 0.27549, 0.43434, 0.25947, 0.01236,
0.0, 0.42255, 0.5073, 0.38113, 0.10205, 0.45306, 0.00477, 0.0, 0.37107, 0.14947,
0.27564, 0.70923, 0.0562, 0.05902, 0.21613, 0.25713, 0.39205, 0.0, 0.0, 0.43975,
0.70342, 0.0, 0.50664, 0.11172, 0.10631, 0.05909, 0.79553, 0.1349, 0.07048, 0.0,
0.53473, 0.0, 0.0, 0.31553, 0.48961, 0.0, 0.06141, 0.38112, 1.22286, 0.33563,
0.19423, 0.06941, 0.2862, 0.0343, 0.64844, 0.17025, 0.0, 0.62452, 0.0, 0.0,
0.08317, 0.0, 0.10109, 0.09981, 0.0, 0.369, 0.01377, 0.18212, 0.13574, 0.37456,
0.03428, 0.34665, 0.47843, 0.0, 0.0, 0.0053, 0.23513, 0.0, 0.13714, 0.0,
0.05245, 0.32722, 0.0, 0.05677, 0.31737, 0.10693, 0.62225, 0.53793, 0.20858, 0.04239,
0.35165, 0.02668, 0.0, 0.03544, 0.27847, 0.0, 0.0, 0.04481, 0.0, 0.16931,
0.01964, 0.0, 0.01786, 0.24306, 8e-05, 0.0, 0.0, 0.02659, 0.0, 0.0,
0.0599, 0.41067, 0.0, 0.00589, 0.17132, 0.09665, 0.39494, 0.0, 0.0, 0.08364,
0.07752, 0.00266, 1e-05, 0.07468, 0.0, 0.00754, 0.19101, 0.28241, 0.0, 0.07648,
0.02461, 0.0, 0.36781, 0.14567, 0.00504, 0.0, 0.0, 0.02592, 0.01688, 0.06218,
0.0, 0.01588, 0.0, 0.0, 0.01979, 0.30657, 0.15687, 0.00331, 0.04598, 0.04678,
0.0, 0.0, 0.36563, 0.07478, 0.17633, 0.08055, 0.0, 0.0097, 0.0, 0.0,
0.01385, 0.00765, 0.12829, 0.0679, 0.1493, 0.01366, 0.07352, 0.01161, 0.0267, 0.05016,
0.09829, 0.0705, 0.0, 0.0, 0.04273, 0.0, 0.0716, 0.04736, 0.00187, 0.04349,
0.05556, 0.00092, 0.0, 0.0052, 0.05377, 0.0004, 0.02759, 0.0, 0.0, 0.61669,
0.02357, 0.01095, 0.00227, 0.55783, 0.0, 0.08453, 0.12306, 0.0, 0.04116, 0.0,
0.00134, 0.59121, 0.0, 0.01725, 0.0011, 0.00079, 0.0, 0.0, 0.00968, 0.04991,
0.03231, 0.0, 0.02791, 0.0, 0.12359, 0.16621, 3e-05, 0.0, 0.04995, 0.01438,
0.06546, 0.0, 7e-05, 0.0, 0.07103, 0.00683, 0.01083, 1e-05, 0.01107, 0.00693,
0.0, 0.06917, 0.0, 0.01422, 0.0343, 0.0, 0.00705, 0.34537, 0.0, 0.01165,
0.00372, 0.2154, 0.57886, 0.08228, 0.00332, 0.0735, 0.0, 0.05252, 0.03644, 0.03541,
0.23112, 0.01512, 0.0, 0.09462, 0.00031, 0.06564, 0.0, 0.0, 0.0, 0.01107,
0.00034, 7e-05, 0.12024, 0.01307, 3e-05, 0.0789, 0.02932, 0.0, 0.32752, 0.45147,
0.0, 0.22466, 0.0, 0.02007, 0.00872, 0.0, 0.0, 1e-05, 0.36416, 0.00015,
0.19467, 0.0, 0.0, 0.53572, 0.32223, 0.12186, 0.0483, 0.00779, 0.3339, 0.00013,
0.00082, 0.0, 0.0, 0.0, 0.0, 0.10405, 0.0, 0.4502, 0.0051, 0.08296,
0.00216, 0.04353, 0.12367, 0.0, 0.14389, 0.0, 0.0, 0.36673, 0.0, 0.0,
0.34636, 0.0, 0.0001, 0.01351, 0.00034, 0.01907, 0.00791, 0.0, 0.00129, 0.0,
0.40499, 0.0, 0.0, 0.08366, 0.0, 0.0, 0.25584, 0.57061, 0.70507, 0.0,
0.0, 0.18143, 0.42539, 0.66514, 0.0, 0.0, 0.29804, 0.0, 0.28829, 0.41273,
0.50942, 0.0, 0.09178, 0.20272, 0.41303, 6e-05, 0.02448, 0.48811, 0.0, 0.0818,
0.0, 0.07639, 0.65981, 0.00096, 0.0, 0.22846, 0.70347, 0.43426, 0.0, 0.40663,
0.01652, 0.09416, 0.0, 0.02656, 0.56497, 0.0, 0.0, 0.0, 0.03001, 0.0,
0.71715, 0.0, 0.00192, 0.47048, 0.22631, 0.0, 0.02586, 0.06006, 0.20732, 0.01805,
0.13912, 0.54863, 0.0, 0.51657, 0.00743, 0.10778, 0.0, 0.0, 0.0, 0.0,
0.0, 0.67212, 0.19832, 0.00432, 0.0, 0.00175, 0.06667, 0.41716, 0.12217, 0.31288,
0.0, 0.74852, 0.0, 0.00255, 0.2814, 0.45116, 0.50539, 0.32614, 0.0, 0.30409,
0.0, 0.0, 0.25113, 0.0, 0.22741, 0.1391, 0.02574, 0.00016, 0.0073, 0.45934,
0.23991, 0.02004, 0.34749, 0.0, 0.52377, 0.06326, 0.32335, 0.16302, 0.15746, 0.00364,
0.0, 0.54827, 0.42714, 0.70166, 0.0, 0.0, 0.39795, 0.06715, 0.0, 0.0,
0.23439, 0.00604, 0.20924, 0.1957, 0.39783, 0.0, 0.0, 0.51778, 0.0, 0.0,
0.57082, 0.0, 0.00024, 0.0, 0.74322, 0.00116, 0.0, 0.16356, 0.01133, 0.02243,
0.65346, 0.7895, 0.30318, 0.52492, 0.18114, 0.53485, 0.22016, 2e-05, 0.39816, 0.56479,
0.02864, 0.65234, 0.0, 0.0, 0.0, 0.0992, 0.14987, 0.0, 0.0, 0.07462,
0.16234, 0.0, 0.0, 0.00621, 0.05237, 0.78129, 0.43683, 0.12717, 0.15497, 0.25109,
0.4028, 0.0, 0.2481, 0.84632, 0.00093, 0.02692, 0.0, 0.0, 0.42843, 0.04238,
0.05716, 0.0, 0.0, 0.0, 0.61904, 0.02759, 0.0, 0.0878, 0.19206, 0.61152,
0.0388, 0.23548, 0.0, 0.0, 0.00666, 0.13364, 0.22438, 0.0, 0.63356, 0.36131,
0.457, 0.15553, 0.0, 0.0, 0.02199, 0.00631, 0.1607, 0.47493, 0.01608, 0.0,
0.86933, 0.51457, 0.17658, 0.00092, 0.00659, 0.00155, 0.0, 0.67375, 0.63718, 0.00635,
0.39418, 0.61056, 0.0, 0.0, 0.37985, 0.15329, 0.63039, 0.28826, 0.04915, 0.48761,
0.57095, 0.0, 0.70731, 0.40762, 0.0006, 0.67333, 0.48771, 0.0, 0.17767, 0.30208,
0.41305, 0.66482, 0.47214, 0.51383, 0.0, 0.30166, 0.01172, 0.11783, 0.36782, 0.0,
0.71679, 0.0, 0.00053, 0.0, 0.75962, 0.47075, 7e-05, 0.0, 0.0, 0.0,
0.00012, 0.73663, 0.17536, 0.5773, 0.00318, 0.51136, 0.0, 0.0, 0.00075, 0.00515,
0.47188, 0.41978, 0.78495, 0.14351, 0.00491, 0.0, 0.21411, 0.77982, 0.65693, 0.51292,
0.4017, 0.10142, 0.18035, 0.51624, 0.50906, 0.0, 0.4748, 0.26747, 0.0, 0.23534,
0.0, 0.59324, 0.00676, 0.20496, 0.77803, 0.00729, 0.57775, 0.58682, 0.0, 0.0,
0.26202, 0.54766, 0.11304, 0.00739, 0.01078, 0.00026, 0.00019, 0.0, 0.0552, 0.00478,
0.00887, 0.00143, 0.88311, 0.12395, 0.60467, 0.88719, 0.01793, 0.27321, 0.0071, 0.28893,
0.00426, 0.0135, 0.0, 0.26657, 0.69537, 0.70755, 0.0, 0.5103, 0.73724, 0.00547,
0.62234, 0.0, 0.86454, 0.25019, 0.11372, 0.0, 0.0, 0.48168, 0.01546, 0.04045,
0.03804, 0.22293, 0.02279, 0.00311, 0.38029, 0.01809, 0.0, 0.45164, 0.05918, 0.40769,
0.45002, 0.36323, 0.0, 0.0, 0.40397, 0.00262, 0.0, 0.78498, 0.40938, 0.91316,
0.71599, 0.46511, 0.85203, 0.7996, 0.04825, 0.0, 0.09025, 0.72207, 0.47213, 0.82834,
0.16914, 0.20413, 0.40483, 2e-05, 0.0133, 0.026, 0.0143, 0.22382, 0.81758, 0.54883,
0.00738, 0.0, 0.15307, 0.54968, 0.0, 0.52159, 0.25367, 0.0, 0.68786, 0.41812,
0.43675, 0.0, 0.81874, 0.17509, 0.88778, 0.63771, 0.0, 0.64224, 0.0, 0.0,
0.69858, 0.47271, 0.0, 0.21959, 0.15844, 0.67096, 0.70144, 0.78685, 0.63303, 0.00156,
0.66517, 0.24494, 0.78376, 0.78629, 0.32911, 0.14563, 0.00711, 0.02871, 0.18767, 0.8961,
0.0, 0.58092, 0.8437, 0.30775, 0.74901, 0.45169, 0.0, 0.0, 2e-05, 0.16325,
0.00027, 0.20422, 0.0, 0.92263, 0.84271, 0.84346, 0.64423, 0.0658, 0.55896, 0.04355,
0.0538, 0.19018, 0.82118, 0.0, 0.27977, 0.0, 0.74302, 0.67848, 0.50665, 0.67587,
0.84453, 0.74089, 0.60708, 0.47972, 0.69295, 0.61686, 0.09719, 0.69716, 0.8583, 0.0,
8e-05, 0.24042, 0.17525, 0.07163, 0.31539, 0.80091, 0.87077, 0.98207, 0.64515, 0.6948,
0.00125, 0.02975, 0.90463, 0.00303, 0.0, 0.93436, 0.66711, 0.01799, 0.9924, 0.85188,
0.85912, 0.87112, 0.01973, 0.63834, 0.64741, 0.06465, 0.06521, 0.42098, 0.73724, 0.31299,
0.88215, 0.90051, 0.81997, 0.95985, 0.33599, 0.40494, 0.88442, 0.0, 0.0, 0.83327,
0.79802, 0.35831, 0.01498, 0.9909, 0.08315, 0.66085, 0.66397, 0.94616, 0.81412, 0.83521,
0.95701, 0.72068, 8e-05, 0.62333, 0.09822, 0.76215, 0.87812, 0.93228, 0.00033, 0.0,
0.81552, 0.51051, 0.91455, 0.0, 0.00024, 0.83926, 0.13759, 0.26159, 0.60253, 0.01088,
0.71392, 0.10763, 0.89284, 0.3285, 0.08792, 0.0, 0.85177, 0.79829, 0.87048, 0.65896,
0.82504, 0.76809, 0.38868, 0.50562, 0.69606, 0.83334, 0.31914, 0.27777, 0.78106, 6e-05,
0.0, 0.93466, 0.74669, 0.60927, 0.1728, 0.19641, 0.2739, 0.92478, 0.96385, 0.0,
0.69251, 0.9082, 0.70993, 3e-05, 0.0, 0.75534, 0.08925, 0.50013, 0.59023, 0.01423,
2e-05, 0.12135, 0.85847, 0.00164, 0.8859, 0.00246, 0.51261, 0.30216, 0.86809, 0.69494,
0.00247, 0.89602, 0.59868, 7e-05, 0.91897, 0.64267, 0.91627, 0.23151, 0.44279, 0.79596,
0.01885, 0.29243, 0.28422, 0.99603, 0.91255, 0.67915, 0.89201, 0.77753, 0.60719, 0.95975,
0.18137, 0.1546, 0.64383, 0.96593, 0.19669, 0.82404, 0.98231, 0.27302, 0.18805, 0.0,
0.68261, 0.6296, 0.02293, 0.0, 0.9731, 0.08581, 0.62543, 0.76949, 0.66724, 0.88789,
0.92198, 0.75583, 0.96611, 0.00115, 0.93666, 0.68866, 0.89657, 0.71895, 0.0, 0.94766,
0.96108, 0.40706, 0.95828, 0.0, 0.81978, 0.95118, 0.84892, 0.88329, 0.78456, 0.97352,
0.68649, 0.42083, 0.41782, 0.09697, 0.79667, 0.88364, 0.83115, 0.8813, 0.99415, 0.6738,
0.98341, 0.94438, 0.80001, 0.0, 0.77804, 0.84052, 0.29258, 0.73352, 0.97524, 0.98193,
0.0, 0.02012, 0.97543, 0.96822, 0.81253, 0.77312, 0.24458, 0.93977, 0.76052, 0.60103,
0.91787, 0.98777, 0.76958, 0.76331, 0.71286, 0.87532, 0.6658, 0.4996, 0.0, 0.64545,
0.80568, 0.85656, 0.94331, 0.99354, 0.54307, 0.74909, 0.95161, 0.98588, 0.13247, 0.0,
0.21857, 0.96922, 0.99133, 0.96473, 0.66736, 0.93286, 0.98603, 0.15018, 0.70267, 0.01198,
0.9812, 0.43031, 0.97368, 0.94333, 0.72137, 0.98418, 0.93496, 0.62019, 0.0, 0.99945,
0.89992, 0.71041, 0.6212, 0.52375, 0.3942, 0.67067, 0.92295, 0.98456, 0.98564, 0.8758,
0.99463, 0.94381, 0.94382, 0.7784, 0.1628, 0.90346, 0.00042, 0.98292, 0.97309, 0.69548,
0.96029, 0.0, 0.96545, 0.80257, 0.00023, 0.95191, 0.94038, 0.82768, 0.8995, 0.98584,
0.6277, 0.82213, 0.95606, 0.98726, 0.13339, 0.00032, 0.98997, 0.93163, 0.89086, 0.99028,
0.96303, 0.88884, 0.99528, 0.13969, 0.77352, 0.85036, 0.94541, 0.59115, 0.98512, 0.95694,
0.81543, 0.28429, 0.99578, 0.98808, 0.85223, 0.15575, 0.33364, 0.97604, 0.99155, 0.90054,
0.99208, 0.60712, 0.98134, 0.93541, 1.00718, 0.9823, 0.97079, 0.66414, 0.302, 0.69145,
0.9932, 0.97381, 0.68745, 1.0001, 0.98088, 0.79647, 0.9238, 1.01026, 0.00391, 0.97843,
0.91765, 0.71654, 0.99149, 0.97218, 0.32367, 0.99139, 0.97472, 0.86509, 0.03768, 0.02374,
0.18801, 0.79787, 0.97795, 0.8347, 0.82799, 0.61118, 1.00187, 0.99989, 0.98515, 0.97909,
0.91595, 0.10959, 0.93512, 1.00562, 0.0, 0.69003, 0.98077, 0.7465, 0.97714, 0.9966,
0.99787, 0.99578, 0.97794, 0.60312, 0.99176, 0.95949, 0.6999, 0.97356, 0.96904, 0.0573,
0.13452, 0.97716, 0.96954, 0.99246, 0.21391, 0.9728, 0.98404, 0.5172, 1.00339, 0.91114,
0.00465, 0.51447, 0.63154, 0.69188, 0.92773, 0.99777, 0.88507, 0.40716, 0.99545, 0.95278,
0.98608, 0.8262, 0.99037, 0.96644, 0.93059, 0.98848, 0.98699, 0.96161, 0.65182, 0.97904,
0.98335, 0.69846, 0.98946, 0.80262, 0.9762, 0.53884, 0.81839, 0.992, 0.99598, 0.97057,
0.98038, 0.8616, 0.97676, 0.82606, 0.99322, 0.65537, 0.48884, 1.00215, 0.98887, 0.8692,
0.21477, 0.88879, 0.6925, 0.64932, 0.99068, 1.00011, 0.98418, 0.96835, 0.99108, 0.96094,
0.93733, 0.99821, 0.98724, 0.43077, 0.99156, 1.00126, 0.80593, 0.60752, 0.99285, 0.99398,
0.9992, 0.98307, 0.94107, 0.88788, 1.00109, 0.0001, 0.96391, 0.77974, 0.97745, 0.97589,
0.93147, 0.97971, 0.01167, 0.0, 0.99202, 0.97259, 0.65711, 0.94732, 0.80932, 0.70469,
0.93707, 0.02118, 0.99943, 0.99637, 0.92242, 0.24604, 0.16671, 0.84163, 0.9094, 0.07028,
0.94006, 0.98469, 0.43973, 0.69326, 0.99743, 0.91469, 0.72106, 0.77641, 0.99696, 0.98408,
0.13681, 0.96954, 0.99383, 0.97266, 0.95387, 0.96465, 0.8625, 0.0, 0.9841, 0.98199,
0.97234, 0.76364, 0.08237, 0.99373, 1.00036, 1.00343, 0.17298, 0.72534, 0.9788, 0.8565,
0.0, 0.99744, 0.94527, 0.98732, 0.05989, 0.61549, 0.97663, 1.00705, 0.13951, 0.99877,
0.99125, 0.9255, 0.98095, 0.91349, 0.44588, 0.76609, 0.92098, 0.90367, 0.9631, 0.48437,
0.98063, 0.94242, 0.95703, 0.51909, 0.87705, 0.9849, 0.99502, 0.96808, 0.01861, 1.00171,
0.02385, 0.93644, 0.99133, 0.43765, 0.92777, 1.00347, 0.95968, 0.66915, 0.93299, 0.00205,
0.22353, 0.33501, 0.73898, 0.95762, 0.01194, 0.79213, 0.0, 0.58841, 0.87265, 0.95764,
0.27127, 0.00073, 0.99685, 0.94511, 0.98494, 0.34793, 0.80683, 0.157, 0.55023, 0.91874,
0.98894, 0.25268, 0.87803, 0.0005, 0.57588, 0.13271, 0.13509, 0.72093, 0.98285, 0.95108,
0.04568, 0.92865, 0.9179, 0.97505, 0.86268, 0.8409, 0.92861, 0.28239, 0.93964, 0.15543,
0.84762, 0.8012, 0.79349, 0.0, 0.19849, 0.60645, 0.95696, 0.83704, 0.91742, 0.80044,
0.87414, 0.7175, 0.99337, 0.72689, 0.99542, 0.99566, 0.79942, 0.98478, 0.89981, 0.8228,
0.85063, 0.65399, 0.73885, 0.98612, 0.96821, 0.88325, 0.961, 0.93603, 0.59629, 0.89733,
0.05871, 0.99015, 0.02122, 0.84649, 0.76339, 0.9411, 0.77132, 0.70793, 0.95945, 0.84496,
0.93305, 0.58042, 0.90098, 0.8566, 0.79814, 0.9118, 0.9368, 0.01079, 0.94997, 0.8792
It should be transpose like this new text:
0.0 0.00038 0.00404 0.0 ...
0.0 0.00034 0.00579 0.01225 ...
0.0 0.0 0.01083 0.03703 ...
....
It has been figured out by this script:
ary = np.genfromtxt('phonon2.txt')
one value per line
np.savetxt('foo.txt', ary[:,0:1])
all the values in one line
np.savetxt('foo1.txt', ary[:,0:1].T)
I've a problem with displaying the y-axis labels properly with plotly.
This is my index:
index = ['2015-11','2015-12','2016-01','2016-02','2016-03','2016-04','2016-05',
'2016-06','2016-07','2016-08','2016-09','2016-10','2016-11']
the data
data = [[0.115, 0.077, 0.0, 0.038, 0.0, 0.038, 0.038, 0.077, 0.0, 0.077, 0.077, 0.038],
[0.073, 0.055, 0.083, 0.055, 0.018, 0.055, 0.073, 0.037, 0.028, 0.037, 0.009, 0.0],
[0.099, 0.027, 0.036, 0.045, 0.063, 0.153, 0.027, 0.045, 0.063, 0.027, 0.0, 0.0],
[0.076, 0.038, 0.053, 0.061, 0.098, 0.068, 0.038, 0.061, 0.023, 0.0, 0.0, 0.0],
[0.142, 0.062, 0.027, 0.08, 0.097, 0.044, 0.071, 0.027, 0.0, 0.0, 0.0, 0.0],
[0.169, 0.026, 0.026, 0.026, 0.013, 0.013, 0.091, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.138, 0.121, 0.052, 0.017, 0.034, 0.017, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.297, 0.081, 0.054, 0.054, 0.054, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.095, 0.016, 0.024, 0.04, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.102, 0.023, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.054, 0.027, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.087, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
I create a heatmap with following code:
import plotly.figure_factory as ff
from plotly.offline import iplot
import re
cols = range(12)
index = index
df = pd.DataFrame(data, columns = cols)
df.index = index
x = df.columns.tolist()
y = df.index.tolist()
z = df.values
annotation_text = np.char.mod('%.0f%%', df*100).tolist()
annotation_text = [[re.sub('^0%$','', x) for x in l] for l in annotation_text]
colorscale=[[0.0, 'rgb(248, 248, 255)'],
[0.04, 'rgb(224, 228, 236)'],
[0.08, 'rgb(196, 210, 226)'],
[0.12, 'rgb(158, 178, 226)'],
[0.16, 'rgb(134, 158, 227)'],
[0.2, 'rgb(122, 146, 227)'],
[1.0, 'rgb(65, 105, 225)'],
]
fig = ff.create_annotated_heatmap(z, x=x, y=y, colorscale= colorscale,
annotation_text = annotation_text)
fig.layout.yaxis.autorange = 'reversed'
offline.iplot(fig, filename='annotated_heatmap_color.html')
Which produces the correct heatmap but with the y-axis labels missing
When I change the index to shorter values like '5-11' with
index = [x[3:] for x in index]
the labels show up.
I don't understand the logic behind that and would like to know how to fix it.
Plotly.py uses plotly.js under the hood, which is transforming your date strings to a numerical date format and misplacing them on your non numerical axis.
To explicit a categorical axis you just have to add:
fig.layout.yaxis.type = 'category'
I'm trying to use pandas to create a SVM classifier. I already generated my feature and save it using to_csv from pandas lib. This feature(Color) consists in a whole histogram. So, I have a list of 0 to 255 float values per line. There are 362 lines.
Here is a piece of my code:
if __name__ == '__main__':
train = pd.read_csv('Train.csv',index_col='Object')
XTrain = train['Color']
ColorLabel = train['ColorLabel']
leTrain = LabelEncoder()
leTrain.fit(ColorLabel)
ColorLabel = leTrain.transform(ColorLabel)
svm = SVC()
parameters = {'kernel': ('linear', 'rbf'), 'C': (1, 0.25, 0.5, 0.75,0.05), 'gamma': (0.5,1, 2, 3, 'auto'),
'decision_function_shape': ('ovo', 'ovr'),'class_weight': [{0: 1,1: w2} for w2 in [2, 4, 6, 10,12]]}
clf = GridSearchCV(svm, parameters,verbose = 2)
clf.fit(XTrain, ColorLabel)
Im just trying to fit the feature column Color in SVC.fit, however I receive an error message that says:
return array(a, dtype, copy=False, order=order)
ValueError: could not convert string to float: '[0.0, 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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]'
Here is the head of my Train.csv
Object,Kurtosis,Skewness,Color,TextureLabel,ColorLabel
0122_LSG.jpg,-0.19026044432874611,-0.9694201939544961,"[0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 6.0, 16.0, 90.0, 47.0, 114.0, 126.0, 1918.0, 733.0, 5404.0, 3956.0, 12750.0, 13551.0, 3222.0, 3927.0, 5776.0, 4896.0, 3807.0, 9007.0, 8835.0, 1029.0, 684.0, 495.0, 172.0, 121.0, 125.0, 37.0, 93.0, 31.0, 96.0, 73.0, 7.0, 15.0, 0.0, 22.0, 0.0, 0.0, 7.0, 5.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]",L,S 0075_LSG.jpg,-0.25089779696431913,-0.5106815852572715,"[0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 22.0, 16.0, 461.0, 6.0, 37.0, 216.0, 5.0, 348.0, 45.0, 264.0, 294.0, 316.0, 999.0, 3057.0, 3625.0, 5399.0, 2420.0, 6031.0, 6636.0, 7442.0, 801.0, 5958.0, 7289.0, 11785.0, 6150.0, 8537.0, 4414.0, 398.0, 489.0, 449.0, 155.0, 270.0, 64.0, 230.0, 51.0, 101.0, 121.0, 73.0, 76.0, 36.0, 46.0, 123.0, 45.0, 51.0, 1.0, 78.0, 28.0, 0.0, 4.0, 70.0, 53.0, 0.0, 41.0, 75.0, 4.0, 39.0, 1.0, 94.0,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0, 0.0, 0.0, 0.0, 28.0, 0.0,
I TRIED ALL THE TYPES OF TYPE CASTING THAT I KNOW astype,dtype,converters... PLEASE HELP ME
XTrain =[list(map(float, hist)) for hist in train['Color']]
Plus using ; as sep when reading and writing file
SOLVE IT .