Category : pivot-table

I have below dataframe df = pd.DataFrame() df[‘SubjectArea’] = ["a","b","a","c","a","s","d","b","s","a","s","c","s","z","a"] df[‘Articles’] = [10, 20,5,58,98,15,35,89,47,15,25,145,89,689,25] df[‘NoOfReading’] = [30, 40,45,25,35,88,68,98,45,125,255,np.nan,75,125,265] df SubjectArea Articles NoOfReading 0 a 10 30.0 1 b 20 40.0 2 a 5 45.0 3 c 58 25.0 4 a 98 35.0 5 s 15 88.0 6 d 35 68.0 7 b 89 98.0 8 ..

Read more

I am re-shaping a dataframe as illustrated below. From this: Country Category Series Data 30/03/2020 06/03/2020 13/03/2021 20/04/2020 27/04/2020 03/05/2020 … 01/03/2021 07/03/2021 14/03/2021 21/03/2021 22/03/2021 28/03/2021 04/04/2021 11/04/2021 18/04/2021 25/04/2021 0 United Kingdom Social Timeseries Percentage of adults always/often handwashing … 0.0 0.0 0.0 0.0 0.0 0.0 … NaN 89.0 88.0 89.0 NaN 89.0 ..

Read more

I have a dataframe with input like this: df1 = pd.DataFrame( {‘StoreId’: [244, 391, 246, 246, 130, 130] , ‘PackageStatus’: [‘IN TRANSIT’,’IN TRANSIT’,’IN TRANSIT’, ‘IN TRANSIT’,’IN TRANSIT’,’COLLECTED’,]} ) StoreId PackageStatus 0 244 IN TRANSIT 1 391 IN TRANSIT 2 246 IN TRANSIT 3 246 IN TRANSIT 4 130 IN TRANSIT 5 130 COLLECTED The output ..

Read more

def create_piviot_table(raw_data): df=panda_data_frame(raw_data) table = pd.pivot_table(df,index=[‘system area’],columns=[‘Incident priority’],values=[‘Time to resolution’,’activity ratio %’],aggfunc=np.mean) plt.savefig(‘pivottable.png’) print(table) The pivot table is being showed as a blank white image and has no content in it. I used the dataframe_image and it worked great, but i was not able to save the image to an existing pdf that i am ..

Read more

How can I select all rows with count of rows >= 50. I have the following pandas dataframe. df = pd.DataFrame({"date": ["2000-01-03", "2000-01-04", "2000-01-04", "2000-01-04", "2000-01-04", "2000-01-03", "2000-01-04", "2000-01-05", "2000-01-05", "2000-01-03", "2000-01-05", "2000-01-05", "2000-01-04", "2000-01-05"], "sym": ["A", "A", "A", "A", "A" ,"B", "B","B", "B" ,"C", "C", "C", "D", "E"], "val1": [1, 1, 1, 1, 1, ..

Read more

How can I select all rows with count of rows >= 2? I have the following pandas dataframe. df = pd.DataFrame({"date": ["2000-01-03", "2000-01-04", "2000-01-04", "2000-01-04", "2000-01-04", "2000-01-03", "2000-01-04", "2000-01-05", "2000-01-05", "2000-01-03", "2000-01-05", "2000-01-05", "2000-01-04", "2000-01-05"], "sym": ["A", "A", "A", "A", "A" ,"B", "B","B", "B" ,"C", "C", "C", "D", "E"], "val1": [1, 1, 1, 1, 1, ..

Read more