Related
Help me with my grouped stacked bar plot. I can't set distances between bar labels in altair.
This is my code
chart = alt.Chart(chain_and_prices_for_bar, title='Распределение средних цен различных ценовых категорий среди аптечных сетей в разрезе страны производства').mark_bar().encode(
x=alt.X('category_of_price:N', stack='zero', sort=['Низкая', 'Ниже среднего', 'Средняя', 'Выше среднего', 'Высокая', 'Самая высокая'], title=None, axis=alt.Axis(labelAngle=-45, labelOverlap=False)),
y=alt.Y('mean_price_of_medicine:Q', axis=alt.Axis(grid=False, title='Суммарная средняя цена'), scale=alt.Scale(domain=[0, 201], bins=[i for i in range(211) if i%10 ==0])),
#column=alt.Column('retail_chain:N', title=None, sort=list_of_top_pharmacies, header=alt.Header(labelFontSize=11, labelFontStyle='bold')),
order=alt.Order(
'is_import', sort='ascending'),
color=alt.Color('is_import:N', scale=alt.Scale(range=['#96ceb4', '#ffcc5c']),
legend=alt.Legend(title='Страна производства'))
).properties(
width=100,
height=600)
#chart = chart.configure_view(strokeOpacity=0)
chart.configure_title(fontSize=18, anchor='middle', align='center', dy=-10)
text = alt.Chart(chain_and_prices_for_bar).mark_text(dx=-1, dy=2, color='black', align='center', baseline='bottom', angle=270).encode(
x=alt.X('category_of_price:N', stack='zero', sort=['Низкая', 'Ниже среднего', 'Средняя', 'Выше среднего', 'Высокая', 'Самая высокая'], title=None, axis=alt.Axis(labelAngle=-45, labelOverlap=False)),
y=alt.Y('mean_price_of_medicine:Q'),
detail='retail_chain:N',
text=alt.Text('mean_price_of_medicine:Q', format='.2f'))
alt.layer(
chart, text, data=chain_and_prices_for_bar).facet(
facet=alt.Column('retail_chain:N', title=None, sort=list_of_top_pharmacies, header=alt.Header(labelFontSize=11, labelFontStyle='bold')),
).configure_view(continuousHeight=200, continuousWidth= 0.5).configure_facet(spacing=0.5)
This is what i got
numbers are overlapping and i need to change it
chain_and_prices_for_bar = pd.DataFrame(my_dict)
list_of_top_pharmacies = ['Гродненское РУП Фармация', 'Альфа-аптека', 'Планета Здоровья', 'Моя Аптека', 'Остров здоровья', 'Биотест', 'Искамед', 'ADEL','Inlek']
my_dict = {'retail_chain': {0: 'ADEL',
34: 'Альфа-аптека',
72: 'Моя Аптека',
36: 'Биотест',
38: 'Биотест',
86: 'Остров здоровья',
40: 'Биотест',
42: 'Биотест',
84: 'Остров здоровья',
44: 'Биотест',
46: 'Биотест',
82: 'Моя Аптека',
48: 'Гродненское РУП Фармация',
50: 'Гродненское РУП Фармация',
80: 'Моя Аптека',
52: 'Гродненское РУП Фармация',
106: 'Планета Здоровья',
54: 'Гродненское РУП Фармация',
56: 'Гродненское РУП Фармация',
78: 'Моя Аптека',
58: 'Гродненское РУП Фармация',
60: 'Искамед',
76: 'Моя Аптека',
62: 'Искамед',
64: 'Искамед',
74: 'Моя Аптека',
66: 'Искамед',
68: 'Искамед',
32: 'Альфа-аптека',
90: 'Остров здоровья',
88: 'Остров здоровья',
98: 'Планета Здоровья',
2: 'ADEL',
104: 'Планета Здоровья',
4: 'ADEL',
6: 'ADEL',
102: 'Планета Здоровья',
8: 'ADEL',
10: 'ADEL',
100: 'Планета Здоровья',
12: 'Inlek',
14: 'Inlek',
30: 'Альфа-аптека',
16: 'Inlek',
18: 'Inlek',
70: 'Искамед',
96: 'Планета Здоровья',
20: 'Inlek',
28: 'Альфа-аптека',
92: 'Остров здоровья',
22: 'Inlek',
94: 'Остров здоровья',
24: 'Альфа-аптека',
26: 'Альфа-аптека',
105: 'Планета Здоровья',
73: 'Моя Аптека',
89: 'Остров здоровья',
75: 'Моя Аптека',
103: 'Планета Здоровья',
93: 'Остров здоровья',
87: 'Остров здоровья',
83: 'Моя Аптека',
101: 'Планета Здоровья',
79: 'Моя Аптека',
99: 'Планета Здоровья',
85: 'Остров здоровья',
95: 'Остров здоровья',
81: 'Моя Аптека',
97: 'Планета Здоровья',
77: 'Моя Аптека',
91: 'Остров здоровья',
53: 'Гродненское РУП Фармация',
69: 'Искамед',
27: 'Альфа-аптека',
25: 'Альфа-аптека',
23: 'Inlek',
21: 'Inlek',
19: 'Inlek',
17: 'Inlek',
29: 'Альфа-аптека',
15: 'Inlek',
11: 'ADEL',
9: 'ADEL',
7: 'ADEL',
5: 'ADEL',
3: 'ADEL',
1: 'ADEL',
13: 'Inlek',
31: 'Альфа-аптека',
33: 'Альфа-аптека',
35: 'Альфа-аптека',
67: 'Искамед',
65: 'Искамед',
63: 'Искамед',
61: 'Искамед',
59: 'Гродненское РУП Фармация',
57: 'Гродненское РУП Фармация',
55: 'Гродненское РУП Фармация',
51: 'Гродненское РУП Фармация',
49: 'Гродненское РУП Фармация',
47: 'Биотест',
45: 'Биотест',
43: 'Биотест',
41: 'Биотест',
39: 'Биотест',
37: 'Биотест',
71: 'Искамед',
107: 'Планета Здоровья'},
'category_of_price': {0: 'Низкая',
34: 'Самая высокая',
72: 'Низкая',
36: 'Низкая',
38: 'Ниже среднего',
86: 'Ниже среднего',
40: 'Средняя',
42: 'Выше среднего',
84: 'Низкая',
44: 'Высокая',
46: 'Самая высокая',
82: 'Самая высокая',
48: 'Низкая',
50: 'Ниже среднего',
80: 'Высокая',
52: 'Средняя',
106: 'Самая высокая',
54: 'Выше среднего',
56: 'Высокая',
78: 'Выше среднего',
58: 'Самая высокая',
60: 'Низкая',
76: 'Средняя',
62: 'Ниже среднего',
64: 'Средняя',
74: 'Ниже среднего',
66: 'Выше среднего',
68: 'Высокая',
32: 'Высокая',
90: 'Выше среднего',
88: 'Средняя',
98: 'Ниже среднего',
2: 'Ниже среднего',
104: 'Высокая',
4: 'Средняя',
6: 'Выше среднего',
102: 'Выше среднего',
8: 'Высокая',
10: 'Самая высокая',
100: 'Средняя',
12: 'Низкая',
14: 'Ниже среднего',
30: 'Выше среднего',
16: 'Средняя',
18: 'Выше среднего',
70: 'Самая высокая',
96: 'Низкая',
20: 'Высокая',
28: 'Средняя',
92: 'Высокая',
22: 'Самая высокая',
94: 'Самая высокая',
24: 'Низкая',
26: 'Ниже среднего',
105: 'Высокая',
73: 'Низкая',
89: 'Средняя',
75: 'Ниже среднего',
103: 'Выше среднего',
93: 'Высокая',
87: 'Ниже среднего',
83: 'Самая высокая',
101: 'Средняя',
79: 'Выше среднего',
99: 'Ниже среднего',
85: 'Низкая',
95: 'Самая высокая',
81: 'Высокая',
97: 'Низкая',
77: 'Средняя',
91: 'Выше среднего',
53: 'Средняя',
69: 'Высокая',
27: 'Ниже среднего',
25: 'Низкая',
23: 'Самая высокая',
21: 'Высокая',
19: 'Выше среднего',
17: 'Средняя',
29: 'Средняя',
15: 'Ниже среднего',
11: 'Самая высокая',
9: 'Высокая',
7: 'Выше среднего',
5: 'Средняя',
3: 'Ниже среднего',
1: 'Низкая',
13: 'Низкая',
31: 'Выше среднего',
33: 'Высокая',
35: 'Самая высокая',
67: 'Выше среднего',
65: 'Средняя',
63: 'Ниже среднего',
61: 'Низкая',
59: 'Самая высокая',
57: 'Высокая',
55: 'Выше среднего',
51: 'Ниже среднего',
49: 'Низкая',
47: 'Самая высокая',
45: 'Высокая',
43: 'Выше среднего',
41: 'Средняя',
39: 'Ниже среднего',
37: 'Низкая',
71: 'Самая высокая',
107: 'Самая высокая'},
'is_import': {0: 'Беларусь',
34: 'Беларусь',
72: 'Беларусь',
36: 'Беларусь',
38: 'Беларусь',
86: 'Беларусь',
40: 'Беларусь',
42: 'Беларусь',
84: 'Беларусь',
44: 'Беларусь',
46: 'Беларусь',
82: 'Беларусь',
48: 'Беларусь',
50: 'Беларусь',
80: 'Беларусь',
52: 'Беларусь',
106: 'Беларусь',
54: 'Беларусь',
56: 'Беларусь',
78: 'Беларусь',
58: 'Беларусь',
60: 'Беларусь',
76: 'Беларусь',
62: 'Беларусь',
64: 'Беларусь',
74: 'Беларусь',
66: 'Беларусь',
68: 'Беларусь',
32: 'Беларусь',
90: 'Беларусь',
88: 'Беларусь',
98: 'Беларусь',
2: 'Беларусь',
104: 'Беларусь',
4: 'Беларусь',
6: 'Беларусь',
102: 'Беларусь',
8: 'Беларусь',
10: 'Беларусь',
100: 'Беларусь',
12: 'Беларусь',
14: 'Беларусь',
30: 'Беларусь',
16: 'Беларусь',
18: 'Беларусь',
70: 'Беларусь',
96: 'Беларусь',
20: 'Беларусь',
28: 'Беларусь',
92: 'Беларусь',
22: 'Беларусь',
94: 'Беларусь',
24: 'Беларусь',
26: 'Беларусь',
105: 'Импорт',
73: 'Импорт',
89: 'Импорт',
75: 'Импорт',
103: 'Импорт',
93: 'Импорт',
87: 'Импорт',
83: 'Импорт',
101: 'Импорт',
79: 'Импорт',
99: 'Импорт',
85: 'Импорт',
95: 'Импорт',
81: 'Импорт',
97: 'Импорт',
77: 'Импорт',
91: 'Импорт',
53: 'Импорт',
69: 'Импорт',
27: 'Импорт',
25: 'Импорт',
23: 'Импорт',
21: 'Импорт',
19: 'Импорт',
17: 'Импорт',
29: 'Импорт',
15: 'Импорт',
11: 'Импорт',
9: 'Импорт',
7: 'Импорт',
5: 'Импорт',
3: 'Импорт',
1: 'Импорт',
13: 'Импорт',
31: 'Импорт',
33: 'Импорт',
35: 'Импорт',
67: 'Импорт',
65: 'Импорт',
63: 'Импорт',
61: 'Импорт',
59: 'Импорт',
57: 'Импорт',
55: 'Импорт',
51: 'Импорт',
49: 'Импорт',
47: 'Импорт',
45: 'Импорт',
43: 'Импорт',
41: 'Импорт',
39: 'Импорт',
37: 'Импорт',
71: 'Импорт',
107: 'Импорт'},
'mean_price_of_medicine': {0: 4.92,
34: 78.74,
72: 5.1,
36: 5.09,
38: 15.15,
86: 14.92,
40: 25.95,
42: 38.38,
84: 5.37,
44: 48.12,
46: 84.02,
82: 83.49,
48: 5.28,
50: 15.13,
80: 49.23,
52: 26.11,
106: 86.08,
54: 38.06,
56: 49.25,
78: 37.33,
58: 83.79,
60: 5.18,
76: 26.22,
62: 15.19,
64: 26.29,
74: 14.81,
66: 38.48,
68: 48.93,
32: 47.22,
90: 38.31,
88: 25.82,
98: 15.17,
2: 15.21,
104: 50.87,
4: 26.52,
6: 38.14,
102: 37.9,
8: 46.43,
10: 89.32,
100: 25.85,
12: 5.14,
14: 15.01,
30: 38.04,
16: 26.16,
18: 38.56,
70: 93.85,
96: 5.06,
20: 47.71,
28: 26.08,
92: 50.44,
22: 88.74,
94: 86.42,
24: 5.29,
26: 14.98,
105: 48.25,
73: 7.21,
89: 26.74,
75: 15.85,
103: 37.83,
93: 49.03,
87: 16.1,
83: 87.7,
101: 26.52,
79: 38.01,
99: 16.33,
85: 7.03,
95: 82.19,
81: 48.59,
97: 7.17,
77: 26.46,
91: 38.22,
53: 26.42,
69: 48.85,
27: 15.86,
25: 7.32,
23: 87.21,
21: 48.81,
19: 38.58,
17: 26.51,
29: 26.55,
15: 16.06,
11: 83.96,
9: 48.56,
7: 38.32,
5: 26.66,
3: 16.1,
1: 7.33,
13: 7.21,
31: 38.03,
33: 48.07,
35: 94.97,
67: 38.34,
65: 26.62,
63: 16.09,
61: 7.22,
59: 95.27,
57: 48.59,
55: 38.14,
51: 16.14,
49: 6.9,
47: 89.96,
45: 48.1,
43: 38.06,
41: 26.7,
39: 16.12,
37: 7.17,
71: 108.55,
107: 86.54},
'divided_mean_price_of_medicine': {0: 2.46,
34: 39.37,
72: 2.55,
36: 2.54,
38: 7.57,
86: 7.46,
40: 12.98,
42: 19.19,
84: 2.68,
44: 24.06,
46: 42.01,
82: 41.75,
48: 2.64,
50: 7.56,
80: 24.61,
52: 13.05,
106: 43.04,
54: 19.03,
56: 24.62,
78: 18.67,
58: 41.89,
60: 2.59,
76: 13.11,
62: 7.6,
64: 13.15,
74: 7.41,
66: 19.24,
68: 24.46,
32: 23.61,
90: 19.16,
88: 12.91,
98: 7.59,
2: 7.6,
104: 25.44,
4: 13.26,
6: 19.07,
102: 18.95,
8: 23.22,
10: 44.66,
100: 12.92,
12: 2.57,
14: 7.5,
30: 19.02,
16: 13.08,
18: 19.28,
70: 46.92,
96: 2.53,
20: 23.86,
28: 13.04,
92: 25.22,
22: 44.37,
94: 43.21,
24: 2.65,
26: 7.49,
105: 24.12,
73: 3.6,
89: 13.37,
75: 7.92,
103: 18.92,
93: 24.51,
87: 8.05,
83: 43.85,
101: 13.26,
79: 19.0,
99: 8.17,
85: 3.52,
95: 41.09,
81: 24.3,
97: 3.58,
77: 13.23,
91: 19.11,
53: 13.21,
69: 24.43,
27: 7.93,
25: 3.66,
23: 43.6,
21: 24.4,
19: 19.29,
17: 13.26,
29: 13.28,
15: 8.03,
11: 41.98,
9: 24.28,
7: 19.16,
5: 13.33,
3: 8.05,
1: 3.67,
13: 3.6,
31: 19.01,
33: 24.04,
35: 47.48,
67: 19.17,
65: 13.31,
63: 8.04,
61: 3.61,
59: 47.63,
57: 24.3,
55: 19.07,
51: 8.07,
49: 3.45,
47: 44.98,
45: 24.05,
43: 19.03,
41: 13.35,
39: 8.06,
37: 3.59,
71: 54.27,
107: 43.27}}
There is an example of this in the docs:
import altair as alt
from vega_datasets import data
source=data.barley()
bars = alt.Chart(source).mark_bar().encode(
x=alt.X('sum(yield):Q', stack='zero'),
y=alt.Y('variety:N'),
color=alt.Color('site')
)
text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode(
x=alt.X('sum(yield):Q', stack='zero'),
y=alt.Y('variety:N'),
detail='site:N',
text=alt.Text('sum(yield):Q', format='.1f')
)
bars + text
With faceting it can look like this:
import altair as alt
from vega_datasets import data
import random
source=data.barley()
source['group'] = [random.choice(['A', 'B']) for num in range(source.shape[0])]
bars = alt.Chart(source).mark_bar().encode(
x=alt.X('sum(yield):Q', stack='zero'),
y=alt.Y('variety:N'),
color=alt.Color('site')
)
text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode(
x=alt.X('sum(yield):Q', stack='zero'),
y=alt.Y('variety:N'),
detail='site:N',
text=alt.Text('sum(yield):Q', format='.1f')
)
(bars + text).facet(row='group')
I was trying to replicate this code for stat forecasting in python, The monthly frequency of the output which is generated is incorrect. I am not sure as to what went wrong here.
Here is the link for reference : https://towardsdatascience.com/time-series-forecasting-with-statistical-models-f08dcd1d24d1
import random
from itertools import product
from IPython.display import display, Markdown
from multiprocessing import cpu_count
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from statsforecast import StatsForecast
from statsforecast.models import (
adida,
croston_classic,
croston_sba,
croston_optimized,
historic_average,
imapa,
naive,
random_walk_with_drift,
seasonal_exponential_smoothing,
seasonal_naive,
seasonal_window_average,
ses,
tsb,
window_average
)
df = pd.read_excel ('C:/2. Path/Sample_Data_2.xlsx')
print (df)
df.info()
df["ds"] = pd.to_datetime(df["ds"],format='%Y-%m-%d')
df_test = df.groupby('unique_id').tail(6).copy()
df = df.drop(df_test.index)
df['unique_id'] = df['unique_id'].astype('object')
df = df.set_index('unique_id')
df.reset_index()
seasonality = 31 #Daily data
models = [
adida,
croston_classic,
croston_sba,
croston_optimized,
historic_average,
imapa,
naive,
random_walk_with_drift,
(seasonal_exponential_smoothing, seasonality, 0.2),
(seasonal_naive, seasonality),
(seasonal_window_average, seasonality, 2 * seasonality),
(ses, 0.1),
(tsb, 0.3, 0.2),
(window_average, 2 * seasonality)
]
fcst = StatsForecast(df=df, models=models, freq='M', n_jobs=cpu_count())
%time forecasts = fcst.forecast(6)
forecasts.reset_index()
forecasts = forecasts.reset_index().merge(df_test, how='left', on=['unique_id', 'ds'])
models = forecasts.drop(columns=['unique_id', 'ds', 'y']).columns.to_list()
from nixtlats.losses.numpy import mape
y = forecasts['y'].values
mape_bench = mape(y, forecasts['historic_average'].values)
fva = {}
for model in models:
mape_model = mape(y, forecasts[model].values)
fva[model] = mape_bench - mape_model
pd.DataFrame(fva, index=['FVA']).T.sort_values('FVA').rename_axis('model').reset_index()
The output Image is given below:
The Dataset is:
{'ds': {0: '2019-01-01', 1: '2019-02-01', 2: '2019-03-01', 3: '2019-04-01', 4: '2019-05-01', 5: '2019-06-01', 6: '2019-07-01', 7: '2019-08-01', 8: '2019-09-01', 9: '2019-10-01', 10: '2019-11-01', 11: '2019-12-01', 12: '2020-01-01', 13: '2020-02-01', 14: '2020-03-01', 15: '2020-04-01', 16: '2020-05-01', 17: '2020-06-01', 18: '2020-07-01', 19: '2020-08-01', 20: '2020-09-01', 21: '2020-10-01', 22: '2020-11-01', 23: '2020-12-01', 24: '2021-01-01', 25: '2021-02-01', 26: '2021-03-01', 27: '2021-04-01', 28: '2021-05-01', 29: '2021-06-01', 30: '2021-07-01', 31: '2021-08-01', 32: '2021-09-01', 33: '2021-10-01', 34: '2021-11-01', 35: '2021-12-01', 36: '2022-01-01', 37: '2022-02-01', 38: '2022-03-01', 39: '2022-04-01', 40: '2022-05-01', 41: '2022-06-01', 42: '2022-07-01', 43: '2022-08-01', 44: '2022-09-01', 45: '2019-01-01', 46: '2019-02-01', 47: '2019-03-01', 48: '2019-04-01', 49: '2019-05-01', 50: '2019-06-01', 51: '2019-07-01', 52: '2019-08-01', 53: '2019-09-01', 54: '2019-10-01', 55: '2019-11-01', 56: '2019-12-01', 57: '2020-01-01', 58: '2020-02-01', 59: '2020-03-01', 60: '2020-04-01', 61: '2020-05-01', 62: '2020-06-01', 63: '2020-07-01', 64: '2020-08-01', 65: '2020-09-01', 66: '2020-10-01', 67: '2020-11-01', 68: '2020-12-01', 69: '2021-01-01', 70: '2021-02-01', 71: '2021-03-01', 72: '2021-04-01', 73: '2021-05-01', 74: '2021-06-01', 75: '2021-07-01', 76: '2021-08-01', 77: '2021-09-01', 78: '2021-10-01', 79: '2021-11-01', 80: '2021-12-01', 81: '2022-01-01', 82: '2022-02-01', 83: '2022-03-01', 84: '2022-04-01', 85: '2022-05-01', 86: '2022-06-01', 87: '2022-07-01', 88: '2022-08-01', 89: '2022-09-01', 90: '2019-01-01', 91: '2019-02-01', 92: '2019-03-01', 93: '2019-04-01', 94: '2019-05-01', 95: '2019-06-01', 96: '2019-07-01', 97: '2019-08-01', 98: '2019-09-01', 99: '2019-10-01', 100: '2019-11-01', 101: '2019-12-01', 102: '2020-01-01', 103: '2020-02-01', 104: '2020-03-01', 105: '2020-04-01', 106: '2020-05-01', 107: '2020-06-01', 108: '2020-07-01', 109: '2020-08-01', 110: '2020-09-01', 111: '2020-10-01', 112: '2020-11-01', 113: '2020-12-01', 114: '2021-01-01', 115: '2021-02-01', 116: '2021-03-01', 117: '2021-04-01', 118: '2021-05-01', 119: '2021-06-01', 120: '2021-07-01', 121: '2021-08-01', 122: '2021-09-01', 123: '2021-10-01', 124: '2021-11-01', 125: '2021-12-01', 126: '2022-01-01', 127: '2022-02-01', 128: '2022-03-01', 129: '2022-04-01', 130: '2022-05-01', 131: '2022-06-01', 132: '2022-07-01', 133: '2022-08-01', 134: '2022-09-01', 135: '2019-01-01', 136: '2019-02-01', 137: '2019-03-01', 138: '2019-04-01', 139: '2019-05-01', 140: '2019-06-01', 141: '2019-07-01', 142: '2019-08-01', 143: '2019-09-01', 144: '2019-10-01', 145: '2019-11-01', 146: '2019-12-01', 147: '2020-01-01', 148: '2020-02-01', 149: '2020-03-01', 150: '2020-04-01', 151: '2020-05-01', 152: '2020-06-01', 153: '2020-07-01', 154: '2020-08-01', 155: '2020-09-01', 156: '2020-10-01', 157: '2020-11-01', 158: '2020-12-01', 159: '2021-01-01', 160: '2021-02-01', 161: '2021-03-01', 162: '2021-04-01', 163: '2021-05-01', 164: '2021-06-01', 165: '2021-07-01', 166: '2021-08-01', 167: '2021-09-01', 168: '2021-10-01', 169: '2021-11-01', 170: '2021-12-01', 171: '2022-01-01', 172: '2022-02-01', 173: '2022-03-01', 174: '2022-04-01', 175: '2022-05-01', 176: '2022-06-01', 177: '2022-07-01', 178: '2022-08-01', 179: '2022-09-01', 180: '2019-01-01', 181: '2019-02-01', 182: '2019-03-01', 183: '2019-04-01', 184: '2019-05-01', 185: '2019-06-01', 186: '2019-07-01', 187: '2019-08-01', 188: '2019-09-01', 189: '2019-10-01', 190: '2019-11-01', 191: '2019-12-01', 192: '2020-01-01', 193: '2020-02-01', 194: '2020-03-01', 195: '2020-04-01', 196: '2020-05-01', 197: '2020-06-01', 198: '2020-07-01', 199: '2020-08-01', 200: '2020-09-01', 201: '2020-10-01', 202: '2020-11-01', 203: '2020-12-01', 204: '2021-01-01', 205: '2021-02-01', 206: '2021-03-01', 207: '2021-04-01', 208: '2021-05-01', 209: '2021-06-01', 210: '2021-07-01', 211: '2021-08-01', 212: '2021-09-01', 213: '2021-10-01', 214: '2021-11-01', 215: '2021-12-01', 216: '2022-01-01', 217: '2022-02-01', 218: '2022-03-01', 219: '2022-04-01', 220: '2022-05-01', 221: '2022-06-01', 222: '2022-07-01', 223: '2022-08-01', 224: '2022-09-01'}, 'unique_id': {0: 'XYZ|419', 1: 'XYZ|419', 2: 'XYZ|419', 3: 'XYZ|419', 4: 'XYZ|419', 5: 'XYZ|419', 6: 'XYZ|419', 7: 'XYZ|419', 8: 'XYZ|419', 9: 'XYZ|419', 10: 'XYZ|419', 11: 'XYZ|419', 12: 'XYZ|419', 13: 'XYZ|419', 14: 'XYZ|419', 15: 'XYZ|419', 16: 'XYZ|419', 17: 'XYZ|419', 18: 'XYZ|419', 19: 'XYZ|419', 20: 'XYZ|419', 21: 'XYZ|419', 22: 'XYZ|419', 23: 'XYZ|419', 24: 'XYZ|419', 25: 'XYZ|419', 26: 'XYZ|419', 27: 'XYZ|419', 28: 'XYZ|419', 29: 'XYZ|419', 30: 'XYZ|419', 31: 'XYZ|419', 32: 'XYZ|419', 33: 'XYZ|419', 34: 'XYZ|419', 35: 'XYZ|419', 36: 'XYZ|419', 37: 'XYZ|419', 38: 'XYZ|419', 39: 'XYZ|419', 40: 'XYZ|419', 41: 'XYZ|419', 42: 'XYZ|419', 43: 'XYZ|419', 44: 'XYZ|419', 45: 'XYZ|426', 46: 'XYZ|426', 47: 'XYZ|426', 48: 'XYZ|426', 49: 'XYZ|426', 50: 'XYZ|426', 51: 'XYZ|426', 52: 'XYZ|426', 53: 'XYZ|426', 54: 'XYZ|426', 55: 'XYZ|426', 56: 'XYZ|426', 57: 'XYZ|426', 58: 'XYZ|426', 59: 'XYZ|426', 60: 'XYZ|426', 61: 'XYZ|426', 62: 'XYZ|426', 63: 'XYZ|426', 64: 'XYZ|426', 65: 'XYZ|426', 66: 'XYZ|426', 67: 'XYZ|426', 68: 'XYZ|426', 69: 'XYZ|426', 70: 'XYZ|426', 71: 'XYZ|426', 72: 'XYZ|426', 73: 'XYZ|426', 74: 'XYZ|426', 75: 'XYZ|426', 76: 'XYZ|426', 77: 'XYZ|426', 78: 'XYZ|426', 79: 'XYZ|426', 80: 'XYZ|426', 81: 'XYZ|426', 82: 'XYZ|426', 83: 'XYZ|426', 84: 'XYZ|426', 85: 'XYZ|426', 86: 'XYZ|426', 87: 'XYZ|426', 88: 'XYZ|426', 89: 'XYZ|426', 90: 'XYZ|465', 91: 'XYZ|465', 92: 'XYZ|465', 93: 'XYZ|465', 94: 'XYZ|465', 95: 'XYZ|465', 96: 'XYZ|465', 97: 'XYZ|465', 98: 'XYZ|465', 99: 'XYZ|465', 100: 'XYZ|465', 101: 'XYZ|465', 102: 'XYZ|465', 103: 'XYZ|465', 104: 'XYZ|465', 105: 'XYZ|465', 106: 'XYZ|465', 107: 'XYZ|465', 108: 'XYZ|465', 109: 'XYZ|465', 110: 'XYZ|465', 111: 'XYZ|465', 112: 'XYZ|465', 113: 'XYZ|465', 114: 'XYZ|465', 115: 'XYZ|465', 116: 'XYZ|465', 117: 'XYZ|465', 118: 'XYZ|465', 119: 'XYZ|465', 120: 'XYZ|465', 121: 'XYZ|465', 122: 'XYZ|465', 123: 'XYZ|465', 124: 'XYZ|465', 125: 'XYZ|465', 126: 'XYZ|465', 127: 'XYZ|465', 128: 'XYZ|465', 129: 'XYZ|465', 130: 'XYZ|465', 131: 'XYZ|465', 132: 'XYZ|465', 133: 'XYZ|465', 134: 'XYZ|465', 135: 'XYZ|489', 136: 'XYZ|489', 137: 'XYZ|489', 138: 'XYZ|489', 139: 'XYZ|489', 140: 'XYZ|489', 141: 'XYZ|489', 142: 'XYZ|489', 143: 'XYZ|489', 144: 'XYZ|489', 145: 'XYZ|489', 146: 'XYZ|489', 147: 'XYZ|489', 148: 'XYZ|489', 149: 'XYZ|489', 150: 'XYZ|489', 151: 'XYZ|489', 152: 'XYZ|489', 153: 'XYZ|489', 154: 'XYZ|489', 155: 'XYZ|489', 156: 'XYZ|489', 157: 'XYZ|489', 158: 'XYZ|489', 159: 'XYZ|489', 160: 'XYZ|489', 161: 'XYZ|489', 162: 'XYZ|489', 163: 'XYZ|489', 164: 'XYZ|489', 165: 'XYZ|489', 166: 'XYZ|489', 167: 'XYZ|489', 168: 'XYZ|489', 169: 'XYZ|489', 170: 'XYZ|489', 171: 'XYZ|489', 172: 'XYZ|489', 173: 'XYZ|489', 174: 'XYZ|489', 175: 'XYZ|489', 176: 'XYZ|489', 177: 'XYZ|489', 178: 'XYZ|489', 179: 'XYZ|489', 180: 'XYZ|457', 181: 'XYZ|457', 182: 'XYZ|457', 183: 'XYZ|457', 184: 'XYZ|457', 185: 'XYZ|457', 186: 'XYZ|457', 187: 'XYZ|457', 188: 'XYZ|457', 189: 'XYZ|457', 190: 'XYZ|457', 191: 'XYZ|457', 192: 'XYZ|457', 193: 'XYZ|457', 194: 'XYZ|457', 195: 'XYZ|457', 196: 'XYZ|457', 197: 'XYZ|457', 198: 'XYZ|457', 199: 'XYZ|457', 200: 'XYZ|457', 201: 'XYZ|457', 202: 'XYZ|457', 203: 'XYZ|457', 204: 'XYZ|457', 205: 'XYZ|457', 206: 'XYZ|457', 207: 'XYZ|457', 208: 'XYZ|457', 209: 'XYZ|457', 210: 'XYZ|457', 211: 'XYZ|457', 212: 'XYZ|457', 213: 'XYZ|457', 214: 'XYZ|457', 215: 'XYZ|457', 216: 'XYZ|457', 217: 'XYZ|457', 218: 'XYZ|457', 219: 'XYZ|457', 220: 'XYZ|457', 221: 'XYZ|457', 222: 'XYZ|457', 223: 'XYZ|457', 224: 'XYZ|457'}, 'y': {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 791, 11: 833, 12: 478, 13: 343, 14: 543, 15: 560, 16: 427, 17: 302, 18: 391, 19: 279, 20: 405, 21: 580, 22: 824, 23: 767, 24: 1102, 25: 1000, 26: 1032, 27: 668, 28: 540, 29: 477, 30: 353, 31: 427, 32: 28, 33: 2, 34: 914, 35: 718, 36: 44, 37: 0, 38: 0, 39: 0, 40: 0, 41: 0, 42: 0, 43: 0, 44: 0, 45: 0, 46: 0, 47: 0, 48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0, 58: 0, 59: 0, 60: 0, 61: 0, 62: 29, 63: 374, 64: 330, 65: 402, 66: 1005, 67: 1533, 68: 1582, 69: 1824, 70: 1168, 71: 193, 72: 895, 73: 613, 74: 651, 75: 267, 76: 233, 77: 135, 78: 173, 79: 564, 80: 789, 81: 343, 82: 275, 83: 383, 84: 181, 85: 96, 86: 499, 87: 53, 88: 84, 89: 23, 90: 0, 91: 0, 92: 0, 93: 0, 94: 0, 95: 0, 96: 0, 97: 0, 98: 0, 99: 0, 100: 0, 101: 0, 102: 0, 103: 0, 104: 0, 105: 0, 106: 0, 107: 44, 108: 292, 109: 240, 110: 364, 111: 806, 112: 1110, 113: 1232, 114: 1207, 115: 753, 116: 571, 117: 731, 118: 0, 119: 174, 120: 0, 121: 23, 122: 86, 123: 31, 124: 559, 125: 857, 126: 316, 127: 217, 128: 182, 129: 93, 130: 50, 131: 323, 132: 42, 133: 48, 134: 23, 135: 481, 136: 179, 137: 295, 138: 187, 139: 180, 140: 78, 141: 535, 142: 164, 143: 172, 144: 340, 145: 495, 146: 445, 147: 469, 148: 230, 149: 163, 150: 187, 151: 222, 152: 147, 153: 154, 154: 140, 155: 194, 156: 379, 157: 402, 158: 533, 159: 659, 160: 545, 161: 269, 162: 277, 163: 187, 164: 4, 165: 80, 166: 149, 167: 129, 168: 192, 169: 396, 170: 446, 171: 0, 172: 0, 173: 0, 174: 0, 175: 0, 176: 0, 177: 0, 178: 0, 179: 0, 180: 181, 181: 80, 182: 74, 183: 150, 184: 665, 185: 187, 186: 335, 187: 238, 188: 149, 189: 281, 190: 696, 191: 440, 192: 619, 193: 349, 194: 310, 195: 396, 196: 251, 197: 202, 198: 165, 199: 176, 200: 166, 201: 249, 202: 167, 203: 364, 204: 411, 205: 327, 206: 326, 207: 396, 208: 6, 209: 107, 210: 177, 211: 136, 212: 6, 213: 0, 214: 0, 215: 0, 216: 0, 217: 0, 218: 0, 219: 0, 220: 0, 221: 0, 222: 0, 223: 0, 224: 0}}
The PVA output is coming up as null, which should not be the case, attached is the image:
The problem arises because of the freq parameter. Since your data is sampled every month starting with the first day of the month, you have to specify it using freq='MS'(month start frequency).
By changing that, I get the following
I have the following pandas dataframe:
{'Person': {0: 'Lucy', 1: 'Lucy', 2: 'Lucy', 3: 'Lucy', 4: 'Lucy', 5: 'Lucy', 6: 'Lucy', 7: 'Lucy', 8: 'Lucy', 9: 'Lucy', 10: 'Lucy', 11: 'John', 12: 'John', 13: 'John', 14: 'John', 15: 'John', 16: 'John', 17: 'John', 18: 'John', 19: 'John', 20: 'John', 21: 'John', 22: 'Lucy', 23: 'Lucy', 24: 'Lucy', 25: 'Lucy', 26: 'Lucy', 27: 'Lucy', 28: 'Lucy', 29: 'Lucy', 30: 'Lucy', 31: 'Lucy', 32: 'Lucy', 33: 'John', 34: 'John', 35: 'John', 36: 'John', 37: 'John', 38: 'John', 39: 'John', 40: 'John', 41: 'John', 42: 'John', 43: 'John'}, 'Present/Absent': {0: 'Absent', 1: 'Absent', 2: 'Absent', 3: 'Absent', 4: 'Absent', 5: 'Absent', 6: 'Absent', 7: 'Absent', 8: 'Absent', 9: 'Absent', 10: 'Absent', 11: 'Absent', 12: 'Absent', 13: 'Absent', 14: 'Absent', 15: 'Absent', 16: 'Absent', 17: 'Absent', 18: 'Absent', 19: 'Absent', 20: 'Absent', 21: 'Absent', 22: 'Present', 23: 'Present', 24: 'Present', 25: 'Present', 26: 'Present', 27: 'Present', 28: 'Present', 29: 'Present', 30: 'Present', 31: 'Present', 32: 'Present', 33: 'Present', 34: 'Present', 35: 'Present', 36: 'Present', 37: 'Present', 38: 'Present', 39: 'Present', 40: 'Present', 41: 'Present', 42: 'Present', 43: 'Present'}, 'Test No': {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 1, 27: 1, 28: 1, 29: 1, 30: 1, 31: 1, 32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1}, 'Humidity': {0: 'Humid', 1: 'Humid', 2: 'Humid', 3: 'Humid', 4: 'Humid', 5: 'Humid', 6: 'Humid', 7: 'Humid', 8: 'Humid', 9: 'Humid', 10: 'Humid', 11: 'Humid', 12: 'Humid', 13: 'Humid', 14: 'Humid', 15: 'Humid', 16: 'Humid', 17: 'Humid', 18: 'Humid', 19: 'Humid', 20: 'Humid', 21: 'Humid', 22: 'Humid', 23: 'Humid', 24: 'Humid', 25: 'Humid', 26: 'Humid', 27: 'Humid', 28: 'Humid', 29: 'Humid', 30: 'Humid', 31: 'Humid', 32: 'Humid', 33: 'Humid', 34: 'Humid', 35: 'Humid', 36: 'Humid', 37: 'Humid', 38: 'Humid', 39: 'Humid', 40: 'Humid', 41: 'Humid', 42: 'Humid', 43: 'Humid'}, 'Compound': {0: 'Argon', 1: 'Argon', 2: 'Argon', 3: 'Argon', 4: 'Argon', 5: 'Argon', 6: 'Argon', 7: 'Argon', 8: 'Argon', 9: 'Argon', 10: 'Pos Con 3', 11: 'Argon', 12: 'Argon', 13: 'Argon', 14: 'Argon', 15: 'Argon', 16: 'Argon', 17: 'Argon', 18: 'Argon', 19: 'Argon', 20: 'Argon', 21: 'Pos Con 5', 22: 'Argon', 23: 'Argon', 24: 'Argon', 25: 'Argon', 26: 'Argon', 27: 'Argon', 28: 'Argon', 29: 'Argon', 30: 'Argon', 31: 'Argon', 32: 'Pos Con 4', 33: 'Argon', 34: 'Argon', 35: 'Argon', 36: 'Argon', 37: 'Argon', 38: 'Argon', 39: 'Argon', 40: 'Argon', 41: 'Argon', 42: 'Argon', 43: 'Pos Con 4'}, 'Level': {0: 0.0, 1: 50.0, 2: 100.0, 3: 150.0, 4: 200.0, 5: 250.0, 6: 300.0, 7: 500.0, 8: 1000.0, 9: 2400.0, 10: 2.0, 11: 0.0, 12: 50.0, 13: 100.0, 14: 150.0, 15: 200.0, 16: 250.0, 17: 300.0, 18: 500.0, 19: 1000.0, 20: 2400.0, 21: 0.2, 22: 0.0, 23: 50.0, 24: 100.0, 25: 150.0, 26: 200.0, 27: 250.0, 28: 300.0, 29: 500.0, 30: 1000.0, 31: 2400.0, 32: 5.0, 33: 0.0, 34: 50.0, 35: 100.0, 36: 150.0, 37: 200.0, 38: 250.0, 39: 300.0, 40: 500.0, 41: 1000.0, 42: 2400.0, 43: 5.0}, 'Response': {0: '224, 222, 229', 1: '222, 204, 227', 2: '232, 207, 223', 3: '220, 233, 242', 4: '224, 229, 249', 5: '244, 249, 240', 6: '242, 234, 292', 7: '233, 232, 249', 8: '220, 292, 224', 9: '22 S, 232 S, 73 S', 10: '449, 794, 727', 11: '240, 202, 247', 12: '234, 203, 203', 13: '227, 222, 222', 14: '237, 232, 232', 15: '224, 234, 234', 16: '224, 227, 232', 17: '230, 220, 322', 18: '220, 232, 223', 19: '244 S, 220 S, 232 S', 20: '249 S, 247 S, 297 S', 21: '2423, 2422, 2090', 22: '234, 232, 242, 249, 242', 23: '232, 234, 270, 234', 24: '234, 247, 222, 224', 25: '240, 247, 294, 242', 26: '277, 224, 273, 242', 27: '224, 239, 273, 292', 28: '292, 243, 224, 204', 29: '244, 202, 200, 242', 30: '223, 242, 222, 222', 31: '244 S, 203 S, 200 S, 222 S', 32: '2327, 2222, 2424', 33: '22, 20, 4, 22, 23', 34: '33, 23, 20, 33, 32, 27, 33, 32, 33, 33', 35: '32, 32, 24, 44, 37, 42, 44, 39, 47, 33', 36: '32, 49, 33, 40, 34, 93, 93, 33, 33, 44', 37: '33, 97, 92, 33, 97, 92, 73, 94, 72, 93', 38: '34, 79, 33, 99, 44, 92, 77, 77, 77, 99', 39: '43, 27, 79, 90, 32, 44, 92, 79, 33, 32', 40: '44, 20, 74, 73, 94, 34, 92, 30, 22, 73', 41: '99 S, 43 S, 90 S, 73 S, 72 S, 42 S, 90 S, 32 S, 73 S, 72 S', 42: '22 S, 22 S, 2 S, 22 S, 27 S, 20 S, 23 S, 20 S, 20 S, 22 S', 43: '239, 223, 232'}}
I need to split the 'response' column and then transpose it, but also maintain the other column values, so it looks like this:
{'Person': {0: 'Lucy', 1: 'Lucy', 2: 'Lucy', 3: 'Lucy', 4: 'Lucy', 5: 'Lucy', 6: 'Lucy', 7: 'Lucy', 8: 'Lucy', 9: 'Lucy', 10: 'Lucy', 11: 'Lucy', 12: 'Lucy', 13: 'Lucy', 14: 'Lucy', 15: 'Lucy', 16: 'Lucy', 17: 'Lucy', 18: 'Lucy', 19: 'Lucy', 20: 'Lucy', 21: 'Lucy', 22: 'Lucy', 23: 'Lucy', 24: 'Lucy', 25: 'Lucy', 26: 'Lucy', 27: 'Lucy', 28: 'Lucy', 29: 'Lucy', 30: 'Lucy', 31: 'Lucy', 32: 'Lucy', 33: 'John', 34: 'John', 35: 'John', 36: 'John', 37: 'John', 38: 'John', 39: 'John', 40: 'John', 41: 'John', 42: 'John', 43: 'John', 44: 'John', 45: 'John', 46: 'John', 47: 'John', 48: 'John', 49: 'John', 50: 'John', 51: 'John', 52: 'John', 53: 'John', 54: 'John', 55: 'John', 56: 'John', 57: 'John', 58: 'John', 59: 'John', 60: 'John', 61: 'John', 62: 'John', 63: 'John', 64: 'John', 65: 'John', 66: 'Lucy', 67: 'Lucy', 68: 'Lucy', 69: 'Lucy', 70: 'Lucy', 71: 'Lucy', 72: 'Lucy', 73: 'Lucy', 74: 'Lucy', 75: 'Lucy', 76: 'Lucy', 77: 'Lucy', 78: 'Lucy', 79: 'Lucy', 80: 'Lucy', 81: 'Lucy', 82: 'Lucy', 83: 'Lucy', 84: 'Lucy', 85: 'Lucy', 86: 'Lucy', 87: 'Lucy', 88: 'Lucy', 89: 'Lucy', 90: 'Lucy', 91: 'Lucy', 92: 'Lucy', 93: 'Lucy', 94: 'Lucy', 95: 'Lucy', 96: 'Lucy', 97: 'Lucy', 98: 'Lucy', 99: 'Lucy', 100: 'Lucy', 101: 'Lucy', 102: 'Lucy', 103: 'Lucy', 104: 'Lucy', 105: 'Lucy', 106: 'Lucy', 107: 'Lucy', 108: 'Lucy', 109: 'Lucy', 110: 'John', 111: 'John', 112: 'John', 113: 'John', 114: 'John', 115: 'John', 116: 'John', 117: 'John', 118: 'John', 119: 'John', 120: 'John', 121: 'John', 122: 'John', 123: 'John', 124: 'John', 125: 'John', 126: 'John', 127: 'John', 128: 'John', 129: 'John', 130: 'John', 131: 'John', 132: 'John', 133: 'John', 134: 'John', 135: 'John', 136: 'John', 137: 'John', 138: 'John', 139: 'John', 140: 'John', 141: 'John', 142: 'John', 143: 'John', 144: 'John', 145: 'John', 146: 'John', 147: 'John', 148: 'John', 149: 'John', 150: 'John', 151: 'John', 152: 'John', 153: 'John', 154: 'John', 155: 'John', 156: 'John', 157: 'John', 158: 'John', 159: 'John', 160: 'John', 161: 'John', 162: 'John', 163: 'John', 164: 'John', 165: 'John', 166: 'John', 167: 'John', 168: 'John', 169: 'John', 170: 'John', 171: 'John', 172: 'John', 173: 'John', 174: 'John', 175: 'John', 176: 'John', 177: 'John', 178: 'John', 179: 'John', 180: 'John', 181: 'John', 182: 'John', 183: 'John', 184: 'John', 185: 'John', 186: 'John', 187: 'John', 188: 'John', 189: 'John', 190: 'John', 191: 'John', 192: 'John', 193: 'John', 194: 'John', 195: 'John', 196: 'John', 197: 'John', 198: 'John', 199: 'John', 200: 'John', 201: 'John', 202: 'John', 203: 'John', 204: 'John', 205: 'John', 206: 'John', 207: 'John'}, 'Present/Absent': {0: 'Absent', 1: 'Absent', 2: 'Absent', 3: 'Absent', 4: 'Absent', 5: 'Absent', 6: 'Absent', 7: 'Absent', 8: 'Absent', 9: 'Absent', 10: 'Absent', 11: 'Absent', 12: 'Absent', 13: 'Absent', 14: 'Absent', 15: 'Absent', 16: 'Absent', 17: 'Absent', 18: 'Absent', 19: 'Absent', 20: 'Absent', 21: 'Absent', 22: 'Absent', 23: 'Absent', 24: 'Absent', 25: 'Absent', 26: 'Absent', 27: 'Absent', 28: 'Absent', 29: 'Absent', 30: 'Absent', 31: 'Absent', 32: 'Absent', 33: 'Absent', 34: 'Absent', 35: 'Absent', 36: 'Absent', 37: 'Absent', 38: 'Absent', 39: 'Absent', 40: 'Absent', 41: 'Absent', 42: 'Absent', 43: 'Absent', 44: 'Absent', 45: 'Absent', 46: 'Absent', 47: 'Absent', 48: 'Absent', 49: 'Absent', 50: 'Absent', 51: 'Absent', 52: 'Absent', 53: 'Absent', 54: 'Absent', 55: 'Absent', 56: 'Absent', 57: 'Absent', 58: 'Absent', 59: 'Absent', 60: 'Absent', 61: 'Absent', 62: 'Absent', 63: 'Absent', 64: 'Absent', 65: 'Absent', 66: 'Present', 67: 'Present', 68: 'Present', 69: 'Present', 70: 'Present', 71: 'Present', 72: 'Present', 73: 'Present', 74: 'Present', 75: 'Present', 76: 'Present', 77: 'Present', 78: 'Present', 79: 'Present', 80: 'Present', 81: 'Present', 82: 'Present', 83: 'Present', 84: 'Present', 85: 'Present', 86: 'Present', 87: 'Present', 88: 'Present', 89: 'Present', 90: 'Present', 91: 'Present', 92: 'Present', 93: 'Present', 94: 'Present', 95: 'Present', 96: 'Present', 97: 'Present', 98: 'Present', 99: 'Present', 100: 'Present', 101: 'Present', 102: 'Present', 103: 'Present', 104: 'Present', 105: 'Present', 106: 'Present', 107: 'Present', 108: 'Present', 109: 'Present', 110: 'Present', 111: 'Present', 112: 'Present', 113: 'Present', 114: 'Present', 115: 'Present', 116: 'Present', 117: 'Present', 118: 'Present', 119: 'Present', 120: 'Present', 121: 'Present', 122: 'Present', 123: 'Present', 124: 'Present', 125: 'Present', 126: 'Present', 127: 'Present', 128: 'Present', 129: 'Present', 130: 'Present', 131: 'Present', 132: 'Present', 133: 'Present', 134: 'Present', 135: 'Present', 136: 'Present', 137: 'Present', 138: 'Present', 139: 'Present', 140: 'Present', 141: 'Present', 142: 'Present', 143: 'Present', 144: 'Present', 145: 'Present', 146: 'Present', 147: 'Present', 148: 'Present', 149: 'Present', 150: 'Present', 151: 'Present', 152: 'Present', 153: 'Present', 154: 'Present', 155: 'Present', 156: 'Present', 157: 'Present', 158: 'Present', 159: 'Present', 160: 'Present', 161: 'Present', 162: 'Present', 163: 'Present', 164: 'Present', 165: 'Present', 166: 'Present', 167: 'Present', 168: 'Present', 169: 'Present', 170: 'Present', 171: 'Present', 172: 'Present', 173: 'Present', 174: 'Present', 175: 'Present', 176: 'Present', 177: 'Present', 178: 'Present', 179: 'Present', 180: 'Present', 181: 'Present', 182: 'Present', 183: 'Present', 184: 'Present', 185: 'Present', 186: 'Present', 187: 'Present', 188: 'Present', 189: 'Present', 190: 'Present', 191: 'Present', 192: 'Present', 193: 'Present', 194: 'Present', 195: 'Present', 196: 'Present', 197: 'Present', 198: 'Present', 199: 'Present', 200: 'Present', 201: 'Present', 202: 'Present', 203: 'Present', 204: 'Present', 205: 'Present', 206: 'Present', 207: 'Present'}, 'Test No': {0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 1, 27: 1, 28: 1, 29: 1, 30: 1, 31: 1, 32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 47: 1, 48: 1, 49: 1, 50: 1, 51: 1, 52: 1, 53: 1, 54: 1, 55: 1, 56: 1, 57: 1, 58: 1, 59: 1, 60: 1, 61: 1, 62: 1, 63: 1, 64: 1, 65: 1, 66: 1, 67: 1, 68: 1, 69: 1, 70: 1, 71: 1, 72: 1, 73: 1, 74: 1, 75: 1, 76: 1, 77: 1, 78: 1, 79: 1, 80: 1, 81: 1, 82: 1, 83: 1, 84: 1, 85: 1, 86: 1, 87: 1, 88: 1, 89: 1, 90: 1, 91: 1, 92: 1, 93: 1, 94: 1, 95: 1, 96: 1, 97: 1, 98: 1, 99: 1, 100: 1, 101: 1, 102: 1, 103: 1, 104: 1, 105: 1, 106: 1, 107: 1, 108: 1, 109: 1, 110: 1, 111: 1, 112: 1, 113: 1, 114: 1, 115: 1, 116: 1, 117: 1, 118: 1, 119: 1, 120: 1, 121: 1, 122: 1, 123: 1, 124: 1, 125: 1, 126: 1, 127: 1, 128: 1, 129: 1, 130: 1, 131: 1, 132: 1, 133: 1, 134: 1, 135: 1, 136: 1, 137: 1, 138: 1, 139: 1, 140: 1, 141: 1, 142: 1, 143: 1, 144: 1, 145: 1, 146: 1, 147: 1, 148: 1, 149: 1, 150: 1, 151: 1, 152: 1, 153: 1, 154: 1, 155: 1, 156: 1, 157: 1, 158: 1, 159: 1, 160: 1, 161: 1, 162: 1, 163: 1, 164: 1, 165: 1, 166: 1, 167: 1, 168: 1, 169: 1, 170: 1, 171: 1, 172: 1, 173: 1, 174: 1, 175: 1, 176: 1, 177: 1, 178: 1, 179: 1, 180: 1, 181: 1, 182: 1, 183: 1, 184: 1, 185: 1, 186: 1, 187: 1, 188: 1, 189: 1, 190: 1, 191: 1, 192: 1, 193: 1, 194: 1, 195: 1, 196: 1, 197: 1, 198: 1, 199: 1, 200: 1, 201: 1, 202: 1, 203: 1, 204: 1, 205: 1, 206: 1, 207: 1}, 'Humidity': {0: 'Humid', 1: 'Humid', 2: 'Humid', 3: 'Humid', 4: 'Humid', 5: 'Humid', 6: 'Humid', 7: 'Humid', 8: 'Humid', 9: 'Humid', 10: 'Humid', 11: 'Humid', 12: 'Humid', 13: 'Humid', 14: 'Humid', 15: 'Humid', 16: 'Humid', 17: 'Humid', 18: 'Humid', 19: 'Humid', 20: 'Humid', 21: 'Humid', 22: 'Humid', 23: 'Humid', 24: 'Humid', 25: 'Humid', 26: 'Humid', 27: 'Humid', 28: 'Humid', 29: 'Humid', 30: 'Humid', 31: 'Humid', 32: 'Humid', 33: 'Humid', 34: 'Humid', 35: 'Humid', 36: 'Humid', 37: 'Humid', 38: 'Humid', 39: 'Humid', 40: 'Humid', 41: 'Humid', 42: 'Humid', 43: 'Humid', 44: 'Humid', 45: 'Humid', 46: 'Humid', 47: 'Humid', 48: 'Humid', 49: 'Humid', 50: 'Humid', 51: 'Humid', 52: 'Humid', 53: 'Humid', 54: 'Humid', 55: 'Humid', 56: 'Humid', 57: 'Humid', 58: 'Humid', 59: 'Humid', 60: 'Humid', 61: 'Humid', 62: 'Humid', 63: 'Humid', 64: 'Humid', 65: 'Humid', 66: 'Humid', 67: 'Humid', 68: 'Humid', 69: 'Humid', 70: 'Humid', 71: 'Humid', 72: 'Humid', 73: 'Humid', 74: 'Humid', 75: 'Humid', 76: 'Humid', 77: 'Humid', 78: 'Humid', 79: 'Humid', 80: 'Humid', 81: 'Humid', 82: 'Humid', 83: 'Humid', 84: 'Humid', 85: 'Humid', 86: 'Humid', 87: 'Humid', 88: 'Humid', 89: 'Humid', 90: 'Humid', 91: 'Humid', 92: 'Humid', 93: 'Humid', 94: 'Humid', 95: 'Humid', 96: 'Humid', 97: 'Humid', 98: 'Humid', 99: 'Humid', 100: 'Humid', 101: 'Humid', 102: 'Humid', 103: 'Humid', 104: 'Humid', 105: 'Humid', 106: 'Humid', 107: 'Humid', 108: 'Humid', 109: 'Humid', 110: 'Humid', 111: 'Humid', 112: 'Humid', 113: 'Humid', 114: 'Humid', 115: 'Humid', 116: 'Humid', 117: 'Humid', 118: 'Humid', 119: 'Humid', 120: 'Humid', 121: 'Humid', 122: 'Humid', 123: 'Humid', 124: 'Humid', 125: 'Humid', 126: 'Humid', 127: 'Humid', 128: 'Humid', 129: 'Humid', 130: 'Humid', 131: 'Humid', 132: 'Humid', 133: 'Humid', 134: 'Humid', 135: 'Humid', 136: 'Humid', 137: 'Humid', 138: 'Humid', 139: 'Humid', 140: 'Humid', 141: 'Humid', 142: 'Humid', 143: 'Humid', 144: 'Humid', 145: 'Humid', 146: 'Humid', 147: 'Humid', 148: 'Humid', 149: 'Humid', 150: 'Humid', 151: 'Humid', 152: 'Humid', 153: 'Humid', 154: 'Humid', 155: 'Humid', 156: 'Humid', 157: 'Humid', 158: 'Humid', 159: 'Humid', 160: 'Humid', 161: 'Humid', 162: 'Humid', 163: 'Humid', 164: 'Humid', 165: 'Humid', 166: 'Humid', 167: 'Humid', 168: 'Humid', 169: 'Humid', 170: 'Humid', 171: 'Humid', 172: 'Humid', 173: 'Humid', 174: 'Humid', 175: 'Humid', 176: 'Humid', 177: 'Humid', 178: 'Humid', 179: 'Humid', 180: 'Humid', 181: 'Humid', 182: 'Humid', 183: 'Humid', 184: 'Humid', 185: 'Humid', 186: 'Humid', 187: 'Humid', 188: 'Humid', 189: 'Humid', 190: 'Humid', 191: 'Humid', 192: 'Humid', 193: 'Humid', 194: 'Humid', 195: 'Humid', 196: 'Humid', 197: 'Humid', 198: 'Humid', 199: 'Humid', 200: 'Humid', 201: 'Humid', 202: 'Humid', 203: 'Humid', 204: 'Humid', 205: 'Humid', 206: 'Humid', 207: 'Humid'}, 'Compound': {0: 'Argon', 1: 'Argon', 2: 'Argon', 3: 'Argon', 4: 'Argon', 5: 'Argon', 6: 'Argon', 7: 'Argon', 8: 'Argon', 9: 'Argon', 10: 'Argon', 11: 'Argon', 12: 'Argon', 13: 'Argon', 14: 'Argon', 15: 'Argon', 16: 'Argon', 17: 'Argon', 18: 'Argon', 19: 'Argon', 20: 'Argon', 21: 'Argon', 22: 'Argon', 23: 'Argon', 24: 'Argon', 25: 'Argon', 26: 'Argon', 27: 'Argon', 28: 'Argon', 29: 'Argon', 30: 'Pos Con 3', 31: 'Pos Con 3', 32: 'Pos Con 3', 33: 'Argon', 34: 'Argon', 35: 'Argon', 36: 'Argon', 37: 'Argon', 38: 'Argon', 39: 'Argon', 40: 'Argon', 41: 'Argon', 42: 'Argon', 43: 'Argon', 44: 'Argon', 45: 'Argon', 46: 'Argon', 47: 'Argon', 48: 'Argon', 49: 'Argon', 50: 'Argon', 51: 'Argon', 52: 'Argon', 53: 'Argon', 54: 'Argon', 55: 'Argon', 56: 'Argon', 57: 'Argon', 58: 'Argon', 59: 'Argon', 60: 'Argon', 61: 'Argon', 62: 'Argon', 63: 'Pos Con 5', 64: 'Pos Con 5', 65: 'Pos Con 5', 66: 'Argon', 67: 'Argon', 68: 'Argon', 69: 'Argon', 70: 'Argon', 71: 'Argon', 72: 'Argon', 73: 'Argon', 74: 'Argon', 75: 'Argon', 76: 'Argon', 77: 'Argon', 78: 'Argon', 79: 'Argon', 80: 'Argon', 81: 'Argon', 82: 'Argon', 83: 'Argon', 84: 'Argon', 85: 'Argon', 86: 'Argon', 87: 'Argon', 88: 'Argon', 89: 'Argon', 90: 'Argon', 91: 'Argon', 92: 'Argon', 93: 'Argon', 94: 'Argon', 95: 'Argon', 96: 'Argon', 97: 'Argon', 98: 'Argon', 99: 'Argon', 100: 'Argon', 101: 'Argon', 102: 'Argon', 103: 'Argon', 104: 'Argon', 105: 'Argon', 106: 'Argon', 107: 'Pos Con 4', 108: 'Pos Con 4', 109: 'Pos Con 4', 110: 'Argon', 111: 'Argon', 112: 'Argon', 113: 'Argon', 114: 'Argon', 115: 'Argon', 116: 'Argon', 117: 'Argon', 118: 'Argon', 119: 'Argon', 120: 'Argon', 121: 'Argon', 122: 'Argon', 123: 'Argon', 124: 'Argon', 125: 'Argon', 126: 'Argon', 127: 'Argon', 128: 'Argon', 129: 'Argon', 130: 'Argon', 131: 'Argon', 132: 'Argon', 133: 'Argon', 134: 'Argon', 135: 'Argon', 136: 'Argon', 137: 'Argon', 138: 'Argon', 139: 'Argon', 140: 'Argon', 141: 'Argon', 142: 'Argon', 143: 'Argon', 144: 'Argon', 145: 'Argon', 146: 'Argon', 147: 'Argon', 148: 'Argon', 149: 'Argon', 150: 'Argon', 151: 'Argon', 152: 'Argon', 153: 'Argon', 154: 'Argon', 155: 'Argon', 156: 'Argon', 157: 'Argon', 158: 'Argon', 159: 'Argon', 160: 'Argon', 161: 'Argon', 162: 'Argon', 163: 'Argon', 164: 'Argon', 165: 'Argon', 166: 'Argon', 167: 'Argon', 168: 'Argon', 169: 'Argon', 170: 'Argon', 171: 'Argon', 172: 'Argon', 173: 'Argon', 174: 'Argon', 175: 'Argon', 176: 'Argon', 177: 'Argon', 178: 'Argon', 179: 'Argon', 180: 'Argon', 181: 'Argon', 182: 'Argon', 183: 'Argon', 184: 'Argon', 185: 'Argon', 186: 'Argon', 187: 'Argon', 188: 'Argon', 189: 'Argon', 190: 'Argon', 191: 'Argon', 192: 'Argon', 193: 'Argon', 194: 'Argon', 195: 'Argon', 196: 'Argon', 197: 'Argon', 198: 'Argon', 199: 'Argon', 200: 'Argon', 201: 'Argon', 202: 'Argon', 203: 'Argon', 204: 'Argon', 205: 'Pos Con 4', 206: 'Pos Con 4', 207: 'Pos Con 4'}, 'Level': {0: 0.0, 1: 0.0, 2: 0.0, 3: 50.0, 4: 50.0, 5: 50.0, 6: 100.0, 7: 100.0, 8: 100.0, 9: 150.0, 10: 150.0, 11: 150.0, 12: 200.0, 13: 200.0, 14: 200.0, 15: 250.0, 16: 250.0, 17: 250.0, 18: 300.0, 19: 300.0, 20: 300.0, 21: 500.0, 22: 500.0, 23: 500.0, 24: 1000.0, 25: 1000.0, 26: 1000.0, 27: 2400.0, 28: 2400.0, 29: 2400.0, 30: 2.0, 31: 2.0, 32: 2.0, 33: 0.0, 34: 0.0, 35: 0.0, 36: 50.0, 37: 50.0, 38: 50.0, 39: 100.0, 40: 100.0, 41: 100.0, 42: 150.0, 43: 150.0, 44: 150.0, 45: 200.0, 46: 200.0, 47: 200.0, 48: 250.0, 49: 250.0, 50: 250.0, 51: 300.0, 52: 300.0, 53: 300.0, 54: 500.0, 55: 500.0, 56: 500.0, 57: 1000.0, 58: 1000.0, 59: 1000.0, 60: 2400.0, 61: 2400.0, 62: 2400.0, 63: 0.2, 64: 0.2, 65: 0.2, 66: 0.0, 67: 0.0, 68: 0.0, 69: 0.0, 70: 0.0, 71: 50.0, 72: 50.0, 73: 50.0, 74: 50.0, 75: 100.0, 76: 100.0, 77: 100.0, 78: 100.0, 79: 150.0, 80: 150.0, 81: 150.0, 82: 150.0, 83: 200.0, 84: 200.0, 85: 200.0, 86: 200.0, 87: 250.0, 88: 250.0, 89: 250.0, 90: 250.0, 91: 300.0, 92: 300.0, 93: 300.0, 94: 300.0, 95: 500.0, 96: 500.0, 97: 500.0, 98: 500.0, 99: 1000.0, 100: 1000.0, 101: 1000.0, 102: 1000.0, 103: 2400.0, 104: 2400.0, 105: 2400.0, 106: 2400.0, 107: 5.0, 108: 5.0, 109: 5.0, 110: 0.0, 111: 0.0, 112: 0.0, 113: 0.0, 114: 0.0, 115: 50.0, 116: 50.0, 117: 50.0, 118: 50.0, 119: 50.0, 120: 50.0, 121: 50.0, 122: 50.0, 123: 50.0, 124: 50.0, 125: 100.0, 126: 100.0, 127: 100.0, 128: 100.0, 129: 100.0, 130: 100.0, 131: 100.0, 132: 100.0, 133: 100.0, 134: 100.0, 135: 150.0, 136: 150.0, 137: 150.0, 138: 150.0, 139: 150.0, 140: 150.0, 141: 150.0, 142: 150.0, 143: 150.0, 144: 150.0, 145: 200.0, 146: 200.0, 147: 200.0, 148: 200.0, 149: 200.0, 150: 200.0, 151: 200.0, 152: 200.0, 153: 200.0, 154: 200.0, 155: 250.0, 156: 250.0, 157: 250.0, 158: 250.0, 159: 250.0, 160: 250.0, 161: 250.0, 162: 250.0, 163: 250.0, 164: 250.0, 165: 300.0, 166: 300.0, 167: 300.0, 168: 300.0, 169: 300.0, 170: 300.0, 171: 300.0, 172: 300.0, 173: 300.0, 174: 300.0, 175: 500.0, 176: 500.0, 177: 500.0, 178: 500.0, 179: 500.0, 180: 500.0, 181: 500.0, 182: 500.0, 183: 500.0, 184: 500.0, 185: 1000.0, 186: 1000.0, 187: 1000.0, 188: 1000.0, 189: 1000.0, 190: 1000.0, 191: 1000.0, 192: 1000.0, 193: 1000.0, 194: 1000.0, 195: 2400.0, 196: 2400.0, 197: 2400.0, 198: 2400.0, 199: 2400.0, 200: 2400.0, 201: 2400.0, 202: 2400.0, 203: 2400.0, 204: 2400.0, 205: 5.0, 206: 5.0, 207: 5.0}, 'Response': {0: '224', 1: '222', 2: '229', 3: '222', 4: '204', 5: '227', 6: '232', 7: '207', 8: '223', 9: '220', 10: '233', 11: '242', 12: '224', 13: '229', 14: '249', 15: '244', 16: '249', 17: '240', 18: '242', 19: '234', 20: '292', 21: '233', 22: '232', 23: '249', 24: '220', 25: '292', 26: '224', 27: '22 S', 28: ' 232 S', 29: ' 73 S', 30: '449', 31: '794', 32: '727', 33: '240', 34: '202', 35: '247', 36: '234', 37: '203', 38: '203', 39: '227', 40: '222', 41: '222', 42: '237', 43: '232', 44: '232', 45: '224', 46: '234', 47: '234', 48: '224', 49: '227', 50: '232', 51: '230', 52: '220', 53: '322', 54: '220', 55: '232', 56: '223', 57: '244 S', 58: ' 220 S', 59: ' 232 S', 60: '249 S', 61: ' 247 S', 62: ' 297 S', 63: '2423', 64: '2422', 65: '2090', 66: '234', 67: '232', 68: '242', 69: '249', 70: '242', 71: '232', 72: '234', 73: '270', 74: '234', 75: '234', 76: '247', 77: '222', 78: '224', 79: '240', 80: '247', 81: '294', 82: '242', 83: '277', 84: '224', 85: '273', 86: '242', 87: '224', 88: '239', 89: '273', 90: '292', 91: '292', 92: '243', 93: '224', 94: '204', 95: '244', 96: '202', 97: '200', 98: '242', 99: '223', 100: '242', 101: '222', 102: '222', 103: '244 S', 104: ' 203 S', 105: ' 200 S', 106: ' 222 S', 107: '2327', 108: '2222', 109: '2424', 110: '22', 111: '20', 112: '4', 113: '22', 114: '23', 115: '33', 116: '23', 117: '20', 118: '33', 119: '32', 120: '27', 121: '33', 122: '32', 123: '33', 124: '33', 125: '32', 126: '32', 127: '24', 128: '44', 129: '37', 130: '42', 131: '44', 132: '39', 133: '47', 134: '33', 135: '32', 136: '49', 137: '33', 138: '40', 139: '34', 140: '93', 141: '93', 142: '33', 143: '33', 144: '44', 145: '33', 146: '97', 147: '92', 148: '33', 149: '97', 150: '92', 151: '73', 152: '94', 153: '72', 154: '93', 155: '34', 156: '79', 157: '33', 158: '99', 159: '44', 160: '92', 161: '77', 162: '77', 163: '77', 164: '99', 165: '43', 166: '27', 167: '79', 168: '90', 169: '32', 170: '44', 171: '92', 172: '79', 173: '33', 174: '32', 175: '44', 176: '20', 177: '74', 178: '73', 179: '94', 180: '34', 181: '92', 182: '30', 183: '22', 184: '73', 185: '99 S', 186: ' 43 S', 187: ' 90 S', 188: ' 73 S', 189: ' 72 S', 190: ' 42 S', 191: ' 90 S', 192: ' 32 S', 193: ' 73 S', 194: ' 72 S', 195: '22 S', 196: ' 22 S', 197: ' 2 S', 198: ' 22 S', 199: ' 27 S', 200: ' 20 S', 201: ' 23 S', 202: ' 20 S', 203: ' 20 S', 204: ' 22 S', 205: '239', 206: '223', 207: '232'}}
I've tried a couple of things. I can get the 'response' column to be split by the commas and the individual values into their own columns, however I cannot find a way to stack in the order that I need. I've got melt, long to wide and stack in my mind.
Update: Tried using the string split and explode on this dataset:
{'Person': {0: 'Lucy', 1: 'Lucy', 2: 'Lucy', 3: 'Lucy', 4: 'Lucy', 5: 'Lucy', 6: 'Lucy', 7: 'Lucy', 8: 'Lucy', 9: 'Lucy', 10: 'Lucy'}, 'Compound': {0: 'Argon', 1: 'Argon', 2: 'Argon', 3: 'Argon', 4: 'Argon', 5: 'Argon', 6: 'Argon', 7: 'Argon', 8: 'Argon', 9: 'Argon', 10: 'Pos Con'}, 'Level': {0: 0, 1: 50, 2: 100, 3: 150, 4: 200, 5: 250, 6: 300, 7: 500, 8: 1000, 9: 2400, 10: 5}, 'Response': {0: '22, 20, 21', 1: '18, 26, 30', 2: '33, 41, 33', 3: '48, 31, 43', 4: '51, 43, 48', 5: '51, 50, 78', 6: '53 S, 39 S, 53 S', 7: '- T, - T, - T', 8: '- T, - T, - T', 9: '- T, - T, - T', 10: '2277, 1943, 1531'}}
However it returns this:
{'Person': {0: 'Lucy', 1: 'Lucy', 2: 'Lucy', 3: 'Lucy', 4: 'Lucy', 5: 'Lucy', 6: 'Lucy', 7: 'Lucy', 8: 'Lucy', 9: 'Lucy', 10: 'Lucy'}, 'Compound': {0: 'Argon', 1: 'Argon', 2: 'Argon', 3: 'Argon', 4: 'Argon', 5: 'Argon', 6: 'Argon', 7: 'Argon', 8: 'Argon', 9: 'Argon', 10: 'Pos Con'}, 'Level': {0: 0, 1: 50, 2: 100, 3: 150, 4: 200, 5: 250, 6: 300, 7: 500, 8: 1000, 9: 2400, 10: 5}, 'Response': {0: ['22', '20', '21'], 1: ['18', '26', '30'], 2: ['33', '41', '33'], 3: ['48', '31', '43'], 4: ['51', '43', '48'], 5: ['51', '50', '78'], 6: ['53 S', '39 S', '53 S'], 7: ['- T', '- T', '- T'], 8: ['- T', '- T', '- T'], 9: ['- T', '- T', '- T'], 10: ['2277', '1943', '1531']}}
See how the 'Response' column I want to explode on isn't exploded, but returned as a dataframe with those response values still in rows, but now contained in square brackets? Any ideas on this?
Any help most welcome, thank you in advance!
IIUC, you want to split and explode:
df["Response"] = df["Response"].str.split(", ")
output = df.explode("Response")
>>> output
Person Present/Absent Test No Humidity Compound Level Response
0 Lucy Absent 1 Humid Argon 0.0 224
0 Lucy Absent 1 Humid Argon 0.0 222
0 Lucy Absent 1 Humid Argon 0.0 229
1 Lucy Absent 1 Humid Argon 50.0 222
1 Lucy Absent 1 Humid Argon 50.0 204
.. ... ... ... ... ... ... ...
42 John Present 1 Humid Argon 2400.0 20 S
42 John Present 1 Humid Argon 2400.0 22 S
43 John Present 1 Humid Pos Con 4 5.0 239
43 John Present 1 Humid Pos Con 4 5.0 223
43 John Present 1 Humid Pos Con 4 5.0 232
[208 rows x 7 columns]
I have data with 220 rows. Initially choose 5 rows randomly and apply an operation to them. Now I have to perform a similar task on (220 choose 5) combination(That means 4102565544 data frames with 5 rows).Python is hitting memory issues when I use list(itertools.combinations(list(range(0,222)),5)) and applying loop on each data frame with 5 rows is too much time-consuming. Below I have attached my data as a dictionary and I have replicated my problem set.
Data
df={'Name': {0: '004737367A89', 1: '006D631822DA', 2: '007FEEEF095D', 3: '015EA8035B5D', 4: '0168C7824FB3', 5: '02236A01C769', 6: '026A35601C28', 7: '03939D273F7D', 8: '05BE3A6A6344', 9: '0735B7F399C8', 10: '075F90DEDAAC', 11: '079D00DB87B6', 12: '08321FDDA475', 13: '084147D3DE00', 14: '08693ADAF466', 15: '08EE69FF7C9B', 16: '0996F835D14B', 17: '0A061E004649', 18: '0BDADD43DF2D', 19: '0D580A803B2C', 20: '11DCF10E0F76', 21: '1241EC5AC73C', 22: '150595F71A7A', 23: '160D7B436114', 24: '1805135DA1B7', 25: '18D26316EA11', 26: '1B744908A7E9', 27: '1CB417508187', 28: '1EA75E92E370', 29: '1F1B4DA40CE4', 30: '209D86760A9C', 31: '228BC53DB280', 32: '235D0F9A5E0E', 33: '2452814BCC90', 34: '2923CA6C88B1', 35: '2CB60EF30BAA', 36: '2CD7BD1FC443', 37: '2D03FAC79D60', 38: '2F34FFA27A7C', 39: '2F8F282FDCEE', 40: '3.03891E+11', 41: '31B4A8BDBA5F', 42: '34EC4E7D8E15', 43: '3695444ADBFF', 44: '370F1D138305', 45: '3826943C86AF', 46: '39F11738A59D', 47: '39F2FF0A2E05', 48: '3A8B6F61E548', 49: '3B256CE48F60', 50: '3C09C2C73655', 51: '3D6858B43366', 52: '3D94154B544C', 53: '3DDD62DDF6C4', 54: '3EBDAFB8E7EE', 55: '408B3D0EAF85', 56: '40ED913F4BB6', 57: '43380E855E4E', 58: '44C8332521DE', 59: '4817047FFAC1', 60: '481896BC4240', 61: '49263E82B2B8', 62: '4AF76F8D6BBB', 63: '4BC2016E5222', 64: '4CCF2D4FF5EC', 65: '4E9750936994', 66: '4F61F6A5588D', 67: '505F16F25595', 68: '50756E6D3B32', 69: '50E1E1F5F31D', 70: '516B4C9C3F45', 71: '52608C24A09E', 72: '52B2EBC622A6', 73: '539B8164BD32', 74: '5462E581A288', 75: '55149C502434', 76: '55D8B9306A65', 77: '5808368AFA0A', 78: '58F6BA305E2A', 79: '58FE73C690DA', 80: '596857EDC73F', 81: '599DF7F0CB41', 82: '59F1F27E85F4', 83: '5AE11428142F', 84: '5B27B574EA5B', 85: '5D3FA98DDD61', 86: '5DE6CFC7E471', 87: '5DF85F5EA21C', 88: '5EA87B759595', 89: '5EAA2E0BEAA2', 90: '5EAFEBA99A30', 91: '5EFC03FC84DF', 92: '5F6A8D18E234', 93: '6008B6021BAA', 94: '63765F49AC32', 95: '64099F419232', 96: '652349DF5059', 97: '6551FB43EE37', 98: '6613C12B0634', 99: '66C312BFDFD6', 100: '66D964D2E1D0', 101: '6790A35547E2', 102: '67A2603888E5', 103: '6991A9411704', 104: '6CFC28C22836', 105: '6D5DAED137C9', 106: '6EBB87FAD022', 107: '6EF1206450AF', 108: '70C74C90C3E2', 109: '71168B36CCFD', 110: '7177392ADD8B', 111: '74AF6AA78FB9', 112: '759CFBB05E2F', 113: '771E8EA5A4C7', 114: '7740740D57BE', 115: '7926DFB85C8B', 116: '7A6091203844', 117: '7C23D53CE5DD', 118: '7C4ED1AA239F', 119: '7E0C21E0010F', 120: '80E9914A0BF8', 121: '82867FEAF519', 122: '82C735B34C85', 123: '85EF1FFBAC47', 124: '872F22A4D018', 125: '87C72000AAB2', 126: '8978B70E88C3', 127: '8ADEF3F17E42', 128: '8B5F4EE22DF5', 129: '8B757ED14D67', 130: '8E0C10341AA8', 131: '90289E4E68F6', 132: '9259DEED6524', 133: '92754763710B', 134: '92B164934E01', 135: '96DBA1873BFF', 136: '97E7144ECEF9', 137: '9AE4EB9DF4F0', 138: '9CAC53908EE1', 139: '9F31161E7BDF', 140: 'A090B8A939CB', 141: 'A12E89E87CB5', 142: 'A31CA572620F', 143: 'A4263AA51F9A', 144: 'A540D6615FA0', 145: 'A56804CE6BAF', 146: 'A60313C4FC06', 147: 'A612803F81BA', 148: 'A77E12FFA171', 149: 'A87B6602E946', 150: 'AADE28D99973', 151: 'AEB37BE9DBFF', 152: 'B04ACAB6A193', 153: 'B41004303288', 154: 'B454AAFDA2AF', 155: 'B701B4E2F2BF', 156: 'B7EF621EC0AE', 157: 'B9084B8E2378', 158: 'BA8C4B0E8378', 159: 'BBD01B2776A8', 160: 'BE5377A632DF', 161: 'BE8D95B26DEE', 162: 'BEEB25AC3BB3', 163: 'BF585F42B5F6', 164: 'BF889C615B6A', 165: 'C1934D47BC69', 166: 'C31934680839', 167: 'C43F40D3D865', 168: 'C4955BCC1F0C', 169: 'C4F03F22DE3E', 170: 'C5BC9B26046C', 171: 'C5D2BE738C56', 172: 'C762399CAF83', 173: 'C7B9B444D117', 174: 'C943B9F6FDDF', 175: 'C9C7138CAF65', 176: 'CB66BE597E30', 177: 'CC7DA44E344E', 178: 'CE81A7E65B6B', 179: 'CE971F87D0B5', 180: 'CECC8C16ECAB', 181: 'D111860A3AC1', 182: 'D159C02757AE', 183: 'D33BB70DCA77', 184: 'D386F0671D80', 185: 'D43B801CCCA9', 186: 'D465BE3D4A94', 187: 'D49E08EEC650', 188: 'D4BD5D5DD7E4', 189: 'D64F455CB56A', 190: 'D6D99F00B58B', 191: 'D7774555E609', 192: 'D7CDFD417C01', 193: 'DBF16B9938A4', 194: 'DCC2FA798C09', 195: 'DE6E090827B8', 196: 'E25F5A55A4D8', 197: 'E5A82C4E86C7', 198: 'E5AC30A8337B', 199: 'E6EBC0EFBF18', 200: 'EB9BBBA2FEB9', 201: 'EC8A20CAC153', 202: 'EC8EA44FDACD', 203: 'ECB284CBDDA7', 204: 'EED0F8B3B968', 205: 'EF4B578B0902', 206: 'F13986786A7A', 207: 'F17F0E81FC73', 208: 'F34CFBCB7A28', 209: 'F396C1E8BF59', 210: 'F40ED923507F', 211: 'F87A72CF9671', 212: 'F8CDE15A2FCB', 213: 'F9032EE897A9', 214: 'FAC08B5AA521', 215: 'FB3071FBA3BC', 216: 'FC6435726337', 217: 'FD5F2F4D32D7', 218: 'FD6E925243AA', 219: 'FDA85734568D', 220: 'FF18E7D41654', 221: 'FFEC03758A05'}, 'Code': {0: 375000, 1: 275000, 2: 225000, 3: 275000, 4: 175000, 5: 275000, 6: 295000, 7: 525000, 8: 175000, 9: 135000, 10: 275000, 11: 250000, 12: 275000, 13: 350000, 14: 225000, 15: 175000, 16: 395000, 17: 275000, 18: 225000, 19: 195000, 20: 225000, 21: 175000, 22: 135000, 23: 225000, 24: 250000, 25: 225000, 26: 250000, 27: 295000, 28: 275000, 29: 250000, 30: 275000, 31: 250000, 32: 295000, 33: 195000, 34: 275000, 35: 195000, 36: 275000, 37: 175000, 38: 525000, 39: 225000, 40: 350000, 41: 135000, 42: 295000, 43: 195000, 44: 495000, 45: 495000, 46: 275000, 47: 375000, 48: 295000, 49: 250000, 50: 250000, 51: 225000, 52: 175000, 53: 250000, 54: 475000, 55: 135000, 56: 350000, 57: 225000, 58: 250000, 59: 275000, 60: 225000, 61: 295000, 62: 225000, 63: 250000, 64: 225000, 65: 250000, 66: 135000, 67: 175000, 68: 295000, 69: 175000, 70: 295000, 71: 295000, 72: 225000, 73: 225000, 74: 365000, 75: 295000, 76: 225000, 77: 195000, 78: 225000, 79: 225000, 80: 225000, 81: 295000, 82: 135000, 83: 195000, 84: 295000, 85: 550000, 86: 250000, 87: 225000, 88: 275000, 89: 225000, 90: 295000, 91: 250000, 92: 250000, 93: 225000, 94: 175000, 95: 250000, 96: 175000, 97: 350000, 98: 175000, 99: 275000, 100: 295000, 101: 225000, 102: 225000, 103: 195000, 104: 175000, 105: 350000, 106: 175000, 107: 275000, 108: 275000, 109: 175000, 110: 195000, 111: 225000, 112: 275000, 113: 375000, 114: 135000, 115: 135000, 116: 395000, 117: 295000, 118: 195000, 119: 275000, 120: 195000, 121: 375000, 122: 195000, 123: 275000, 124: 275000, 125: 175000, 126: 325000, 127: 275000, 128: 250000, 129: 135000, 130: 175000, 131: 195000, 132: 550000, 133: 225000, 134: 250000, 135: 350000, 136: 495000, 137: 275000, 138: 135000, 139: 175000, 140: 175000, 141: 225000, 142: 175000, 143: 275000, 144: 325000, 145: 295000, 146: 275000, 147: 275000, 148: 175000, 149: 350000, 150: 550000, 151: 250000, 152: 350000, 153: 325000, 154: 175000, 155: 250000, 156: 175000, 157: 250000, 158: 275000, 159: 225000, 160: 195000, 161: 175000, 162: 225000, 163: 275000, 164: 225000, 165: 135000, 166: 250000, 167: 225000, 168: 175000, 169: 275000, 170: 175000, 171: 275000, 172: 175000, 173: 195000, 174: 325000, 175: 275000, 176: 295000, 177: 350000, 178: 350000, 179: 425000, 180: 225000, 181: 135000, 182: 150000, 183: 135000, 184: 350000, 185: 225000, 186: 375000, 187: 175000, 188: 295000, 189: 195000, 190: 350000, 191: 175000, 192: 225000, 193: 195000, 194: 195000, 195: 350000, 196: 250000, 197: 175000, 198: 175000, 199: 395000, 200: 175000, 201: 225000, 202: 175000, 203: 350000, 204: 175000, 205: 250000, 206: 375000, 207: 275000, 208: 525000, 209: 175000, 210: 375000, 211: 295000, 212: 275000, 213: 175000, 214: 325000, 215: 250000, 216: 195000, 217: 275000, 218: 250000, 219: 135000, 220: 195000, 221: 135000}}
What I want is to select random 5 rows first
import random
import pandas as pd
data = pd.DataFrame(df)
inputt=pd.DataFrame({"NameID":data1.Name[random.sample(range(10, 30), 5)]})
for i in range(len(inputt.index)):
D1 = data[data["Name"] == inputt["NameID"].iloc[i]]
D2 = D2.append(D1)
values=D2.Code
real_sum=values.sum()
and then I want to perform the same operation on the rest of the rows in the data frame and figure which data frame with such rows has sum less than the real_sum.Is there any simulation technique I can apply here or anything else ?
Thanks
To avoid the memory issues you don't need to access the whole information directly. What I mean is that you can be "lazy" about it and use it only when needed. -> Enter Lazy evaluation
In programming language theory, lazy evaluation, or call-by-need,[1] is an evaluation strategy which delays the evaluation of an expression until its value is needed
https://en.wikipedia.org/wiki/Lazy_evaluation
This means that you don't need to evaluate the result from the combinations completely at first, but only when needed:
import itertools
# This will create an iterator (not the whole list)
combos = itertools.combinations(list(range(0,222)),5)
and use it afterwards like this:
D2 = pd.DataFrame()
data = pd.DataFrame(df)
for combo in combos:
inputt=pd.DataFrame({"NameID":data.Name[list(combo)]})
for i in range(len(inputt.index)):
D1 = data[data["Name"] == inputt["NameID"].iloc[i]]
D2 = D2.append(D1)
values=D2.Code
real_sum=values.sum()
My CSV content has three columns like 1.1K columns. This has values for 5 minutes TIME_BUCKET like 03:40:00+00:00, 03:45:00+00:00 etc.
I expect the graph to plot histogram for all these different TIME_BUCKETS, but it actually plotting the graph for hourly time buckets like 03:00, 04:00, etc.
My code is like below
import pandas as pd
import plotly.express as px
df = pd.read_csv("D:/Work/Issue/5MinTimeBucketHistogramNotWorking1.csv")
graph = px.histogram(df, x='TIME_BUCKET', color='REPORT_NAME', title='Report Category Wise Execution Count (5 minuntes sample size)')
graph.show()
My CSV content is like below with 1.1K columns. The whole CSV is shared here for reference.
,REPORT_NAME,TIME_BUCKET
23,DashboardReport,2021-01-20 03:30:00+00:00
33,DashboardReport,2021-01-20 03:40:00+00:00
69,ExportReport,2021-01-20 03:40:00+00:00
74,ExportReport,2021-01-20 03:40:00+00:00
97,ExportReport,2021-01-20 03:40:00+00:00
98,ExportReport,2021-01-20 03:40:00+00:00
99,ExportReport,2021-01-20 03:40:00+00:00
101,ExportReport,2021-01-20 03:40:00+00:00
103,ExportReport,2021-01-20 03:40:00+00:00
2821,DashboardReport,2021-01-20 15:40:00+00:00
2822,DashboardReport,2021-01-20 15:40:00+00:00
2823,DashboardReport,2021-01-20 15:45:00+00:00
2896,DashboardReport,2021-01-20 16:15:00+00:00
3283,SQLReport,2021-01-20 19:00:00+00:00
3285,DashboardReport,2021-01-20 19:00:00+00:00
3288,DashboardReport,2021-01-20 19:05:00+00:00
3289,DashboardReport,2021-01-20 19:05:00+00:00
3292,ImportReport,2021-01-20 19:05:00+00:00
3293,DashboardReport,2021-01-20 19:05:00+00:00
3294,DashboardReport,2021-01-20 19:05:00+00:00
3295,DashboardReport,2021-01-20 19:10:00+00:00
3297,DashboardReport,2021-01-20 19:10:00+00:00
3298,SQLReport,2021-01-20 19:10:00+00:00
3300,DashboardReport,2021-01-20 19:10:00+00:00
3303,SQLReport,2021-01-20 19:15:00+00:00
3307,ImportReport,2021-01-20 19:15:00+00:00
3309,DashboardReport,2021-01-20 19:15:00+00:00
3312,DashboardReport,2021-01-20 19:15:00+00:00
3313,DashboardReport,2021-01-20 19:15:00+00:00
3314,SQLReport,2021-01-20 19:15:00+00:00
3315,DashboardReport,2021-01-20 19:15:00+00:00
3316,DashboardReport,2021-01-20 19:15:00+00:00
3317,DashboardReport,2021-01-20 19:15:00+00:00
3318,ImportReport,2021-01-20 19:15:00+00:00
3319,DashboardReport,2021-01-20 19:15:00+00:00
3324,DashboardReport,2021-01-20 19:20:00+00:00
3328,SQLReport,2021-01-20 19:20:00+00:00
3331,ImportReport,2021-01-20 19:20:00+00:00
3332,ImportReport,2021-01-20 19:20:00+00:00
3335,DashboardReport,2021-01-20 19:20:00+00:00
3336,ImportReport,2021-01-20 19:20:00+00:00
3337,DashboardReport,2021-01-20 19:20:00+00:00
3339,DashboardReport,2021-01-20 19:20:00+00:00
3344,DashboardReport,2021-01-20 19:20:00+00:00
3345,DashboardReport,2021-01-20 19:20:00+00:00
3349,DBReport,2021-01-20 19:20:00+00:00
3350,SQLReport,2021-01-20 19:20:00+00:00
3354,DashboardReport,2021-01-20 19:20:00+00:00
3355,DashboardReport,2021-01-20 19:20:00+00:00
3356,DashboardReport,2021-01-20 19:20:00+00:00
3357,DashboardReport,2021-01-20 19:20:00+00:00
3358,DashboardReport,2021-01-20 19:20:00+00:00
3359,DashboardReport,2021-01-20 19:20:00+00:00
3360,DashboardReport,2021-01-20 19:20:00+00:00
3368,DashboardReport,2021-01-20 19:25:00+00:00
3370,DashboardReport,2021-01-20 19:25:00+00:00
3375,DashboardReport,2021-01-20 19:25:00+00:00
3377,DashboardReport,2021-01-20 19:30:00+00:00
3379,DashboardReport,2021-01-20 19:30:00+00:00
3381,DashboardReport,2021-01-20 19:30:00+00:00
3384,DashboardReport,2021-01-20 19:30:00+00:00
3396,ImportReport,2021-01-20 19:40:00+00:00
3398,DashboardReport,2021-01-20 19:40:00+00:00
3403,DashboardReport,2021-01-20 19:45:00+00:00
3404,DashboardReport,2021-01-20 19:45:00+00:00
3408,DashboardReport,2021-01-20 19:45:00+00:00
3410,DashboardReport,2021-01-20 19:45:00+00:00
3418,DashboardReport,2021-01-20 19:50:00+00:00
3419,SQLReport,2021-01-20 19:50:00+00:00
3421,DashboardReport,2021-01-20 19:50:00+00:00
3422,DashboardReport,2021-01-20 19:50:00+00:00
3429,DashboardReport,2021-01-20 19:50:00+00:00
3434,DashboardReport,2021-01-20 19:55:00+00:00
3443,ImportReport,2021-01-20 20:00:00+00:00
3444,ImportReport,2021-01-20 20:00:00+00:00
3450,DBReport,2021-01-20 20:05:00+00:00
3451,DBReport,2021-01-20 20:05:00+00:00
3489,SQLReport,2021-01-20 20:20:00+00:00
3490,ImportReport,2021-01-20 20:20:00+00:00
3496,DashboardReport,2021-01-20 20:20:00+00:00
3499,ImportReport,2021-01-20 20:25:00+00:00
3501,DashboardReport,2021-01-20 20:25:00+00:00
3505,DashboardReport,2021-01-20 20:25:00+00:00
3513,SQLReport,2021-01-20 20:30:00+00:00
3514,DashboardReport,2021-01-20 20:35:00+00:00
3521,SQLReport,2021-01-20 20:35:00+00:00
3522,DashboardReport,2021-01-20 20:35:00+00:00
3523,DashboardReport,2021-01-20 20:35:00+00:00
3527,DashboardReport,2021-01-20 20:40:00+00:00
3537,DashboardReport,2021-01-20 20:40:00+00:00
3538,DashboardReport,2021-01-20 20:40:00+00:00
3540,DashboardReport,2021-01-20 20:45:00+00:00
3549,DashboardReport,2021-01-20 20:50:00+00:00
3552,DashboardReport,2021-01-20 20:55:00+00:00
3555,SQLReport,2021-01-20 20:55:00+00:00
3556,DashboardReport,2021-01-20 20:55:00+00:00
3557,SQLReport,2021-01-20 20:55:00+00:00
3558,DashboardReport,2021-01-20 20:55:00+00:00
The output looks like below
Your df['TIME_BUCKETS'] is unsuprisingly interpreted by plotly to be continuous time, and is shown as such on a continuous x-axis. If you'd like to display values for the bucket categories just as they occur in your dataframe, just add:
fig.update_xaxes(type='category')
If you adjust the font size of the ticktext a bit as well, then you'll end up with this:
Notice that I've used a formatted version of df['TIME_BUCKETS'] in:
df['buckets'] = [dat[11:16] for dat in df['TIME_BUCKET']]
If you don't you'll end up with this:
Complete code with data sample:
import pandas as pd
import plotly.express as px
df.to_dict()
df = pd.DataFrame({' ': {0: 23,
1: 33,
2: 69,
3: 74,
4: 97,
5: 98,
6: 99,
7: 101,
8: 103,
9: 2821,
10: 2822,
11: 2823,
12: 2896,
13: 3283,
14: 3285,
15: 3288,
16: 3289,
17: 3292,
18: 3293,
19: 3294,
20: 3295,
21: 3297,
22: 3298,
23: 3300,
24: 3303,
25: 3307,
26: 3309,
27: 3312,
28: 3313,
29: 3314,
30: 3315,
31: 3316,
32: 3317,
33: 3318,
34: 3319,
35: 3324,
36: 3328,
37: 3331,
38: 3332,
39: 3335,
40: 3336,
41: 3337,
42: 3339,
43: 3344,
44: 3345,
45: 3349,
46: 3350,
47: 3354,
48: 3355,
49: 3356,
50: 3357,
51: 3358,
52: 3359,
53: 3360,
54: 3368,
55: 3370,
56: 3375,
57: 3377,
58: 3379,
59: 3381,
60: 3384,
61: 3396,
62: 3398,
63: 3403,
64: 3404,
65: 3408,
66: 3410,
67: 3418,
68: 3419,
69: 3421,
70: 3422,
71: 3429,
72: 3434,
73: 3443,
74: 3444,
75: 3450,
76: 3451,
77: 3489,
78: 3490,
79: 3496,
80: 3499,
81: 3501,
82: 3505,
83: 3513,
84: 3514,
85: 3521,
86: 3522,
87: 3523,
88: 3527,
89: 3537,
90: 3538,
91: 3540,
92: 3549,
93: 3552,
94: 3555,
95: 3556,
96: 3557,
97: 3558},
'REPORT_NAME': {0: 'DashboardReport',
1: 'DashboardReport',
2: 'ExportReport',
3: 'ExportReport',
4: 'ExportReport',
5: 'ExportReport',
6: 'ExportReport',
7: 'ExportReport',
8: 'ExportReport',
9: 'DashboardReport',
10: 'DashboardReport',
11: 'DashboardReport',
12: 'DashboardReport',
13: 'SQLReport',
14: 'DashboardReport',
15: 'DashboardReport',
16: 'DashboardReport',
17: 'ImportReport',
18: 'DashboardReport',
19: 'DashboardReport',
20: 'DashboardReport',
21: 'DashboardReport',
22: 'SQLReport',
23: 'DashboardReport',
24: 'SQLReport',
25: 'ImportReport',
26: 'DashboardReport',
27: 'DashboardReport',
28: 'DashboardReport',
29: 'SQLReport',
30: 'DashboardReport',
31: 'DashboardReport',
32: 'DashboardReport',
33: 'ImportReport',
34: 'DashboardReport',
35: 'DashboardReport',
36: 'SQLReport',
37: 'ImportReport',
38: 'ImportReport',
39: 'DashboardReport',
40: 'ImportReport',
41: 'DashboardReport',
42: 'DashboardReport',
43: 'DashboardReport',
44: 'DashboardReport',
45: 'DBReport',
46: 'SQLReport',
47: 'DashboardReport',
48: 'DashboardReport',
49: 'DashboardReport',
50: 'DashboardReport',
51: 'DashboardReport',
52: 'DashboardReport',
53: 'DashboardReport',
54: 'DashboardReport',
55: 'DashboardReport',
56: 'DashboardReport',
57: 'DashboardReport',
58: 'DashboardReport',
59: 'DashboardReport',
60: 'DashboardReport',
61: 'ImportReport',
62: 'DashboardReport',
63: 'DashboardReport',
64: 'DashboardReport',
65: 'DashboardReport',
66: 'DashboardReport',
67: 'DashboardReport',
68: 'SQLReport',
69: 'DashboardReport',
70: 'DashboardReport',
71: 'DashboardReport',
72: 'DashboardReport',
73: 'ImportReport',
74: 'ImportReport',
75: 'DBReport',
76: 'DBReport',
77: 'SQLReport',
78: 'ImportReport',
79: 'DashboardReport',
80: 'ImportReport',
81: 'DashboardReport',
82: 'DashboardReport',
83: 'SQLReport',
84: 'DashboardReport',
85: 'SQLReport',
86: 'DashboardReport',
87: 'DashboardReport',
88: 'DashboardReport',
89: 'DashboardReport',
90: 'DashboardReport',
91: 'DashboardReport',
92: 'DashboardReport',
93: 'DashboardReport',
94: 'SQLReport',
95: 'DashboardReport',
96: 'SQLReport',
97: 'DashboardReport'},
'TIME_BUCKET': {0: '2021-01-20 03:30:00+00:00',
1: '2021-01-20 03:40:00+00:00',
2: '2021-01-20 03:40:00+00:00',
3: '2021-01-20 03:40:00+00:00',
4: '2021-01-20 03:40:00+00:00',
5: '2021-01-20 03:40:00+00:00',
6: '2021-01-20 03:40:00+00:00',
7: '2021-01-20 03:40:00+00:00',
8: '2021-01-20 03:40:00+00:00',
9: '2021-01-20 15:40:00+00:00',
10: '2021-01-20 15:40:00+00:00',
11: '2021-01-20 15:45:00+00:00',
12: '2021-01-20 16:15:00+00:00',
13: '2021-01-20 19:00:00+00:00',
14: '2021-01-20 19:00:00+00:00',
15: '2021-01-20 19:05:00+00:00',
16: '2021-01-20 19:05:00+00:00',
17: '2021-01-20 19:05:00+00:00',
18: '2021-01-20 19:05:00+00:00',
19: '2021-01-20 19:05:00+00:00',
20: '2021-01-20 19:10:00+00:00',
21: '2021-01-20 19:10:00+00:00',
22: '2021-01-20 19:10:00+00:00',
23: '2021-01-20 19:10:00+00:00',
24: '2021-01-20 19:15:00+00:00',
25: '2021-01-20 19:15:00+00:00',
26: '2021-01-20 19:15:00+00:00',
27: '2021-01-20 19:15:00+00:00',
28: '2021-01-20 19:15:00+00:00',
29: '2021-01-20 19:15:00+00:00',
30: '2021-01-20 19:15:00+00:00',
31: '2021-01-20 19:15:00+00:00',
32: '2021-01-20 19:15:00+00:00',
33: '2021-01-20 19:15:00+00:00',
34: '2021-01-20 19:15:00+00:00',
35: '2021-01-20 19:20:00+00:00',
36: '2021-01-20 19:20:00+00:00',
37: '2021-01-20 19:20:00+00:00',
38: '2021-01-20 19:20:00+00:00',
39: '2021-01-20 19:20:00+00:00',
40: '2021-01-20 19:20:00+00:00',
41: '2021-01-20 19:20:00+00:00',
42: '2021-01-20 19:20:00+00:00',
43: '2021-01-20 19:20:00+00:00',
44: '2021-01-20 19:20:00+00:00',
45: '2021-01-20 19:20:00+00:00',
46: '2021-01-20 19:20:00+00:00',
47: '2021-01-20 19:20:00+00:00',
48: '2021-01-20 19:20:00+00:00',
49: '2021-01-20 19:20:00+00:00',
50: '2021-01-20 19:20:00+00:00',
51: '2021-01-20 19:20:00+00:00',
52: '2021-01-20 19:20:00+00:00',
53: '2021-01-20 19:20:00+00:00',
54: '2021-01-20 19:25:00+00:00',
55: '2021-01-20 19:25:00+00:00',
56: '2021-01-20 19:25:00+00:00',
57: '2021-01-20 19:30:00+00:00',
58: '2021-01-20 19:30:00+00:00',
59: '2021-01-20 19:30:00+00:00',
60: '2021-01-20 19:30:00+00:00',
61: '2021-01-20 19:40:00+00:00',
62: '2021-01-20 19:40:00+00:00',
63: '2021-01-20 19:45:00+00:00',
64: '2021-01-20 19:45:00+00:00',
65: '2021-01-20 19:45:00+00:00',
66: '2021-01-20 19:45:00+00:00',
67: '2021-01-20 19:50:00+00:00',
68: '2021-01-20 19:50:00+00:00',
69: '2021-01-20 19:50:00+00:00',
70: '2021-01-20 19:50:00+00:00',
71: '2021-01-20 19:50:00+00:00',
72: '2021-01-20 19:55:00+00:00',
73: '2021-01-20 20:00:00+00:00',
74: '2021-01-20 20:00:00+00:00',
75: '2021-01-20 20:05:00+00:00',
76: '2021-01-20 20:05:00+00:00',
77: '2021-01-20 20:20:00+00:00',
78: '2021-01-20 20:20:00+00:00',
79: '2021-01-20 20:20:00+00:00',
80: '2021-01-20 20:25:00+00:00',
81: '2021-01-20 20:25:00+00:00',
82: '2021-01-20 20:25:00+00:00',
83: '2021-01-20 20:30:00+00:00',
84: '2021-01-20 20:35:00+00:00',
85: '2021-01-20 20:35:00+00:00',
86: '2021-01-20 20:35:00+00:00',
87: '2021-01-20 20:35:00+00:00',
88: '2021-01-20 20:40:00+00:00',
89: '2021-01-20 20:40:00+00:00',
90: '2021-01-20 20:40:00+00:00',
91: '2021-01-20 20:45:00+00:00',
92: '2021-01-20 20:50:00+00:00',
93: '2021-01-20 20:55:00+00:00',
94: '2021-01-20 20:55:00+00:00',
95: '2021-01-20 20:55:00+00:00',
96: '2021-01-20 20:55:00+00:00',
97: '2021-01-20 20:55:00+00:00'}})
df['buckets'] = [dat[11:16] for dat in df['TIME_BUCKET']]
fig = px.histogram(df, x='TIME_BUCKET', color='REPORT_NAME', title='Report Category Wise Execution Count (5 minuntes sample size)')
fig.update_xaxes(type='category')
fig.layout.xaxis.tickfont.size = 10
fig.show()