Skip to content

Tag: pandas

How to change y-axis limits on a bar graph?

I have a df, from which Ive indexed europe_n and Ive plotted a bar plot. europe_n (r=5, c=45), looks like this. ; df[‘Country’](string) & df[‘Population’](numeric) variable/s. Which gives me; Objective: Im trying to change my y-axis limit to start from 0, instead of 43,094. I ran t…

Modify output of pandas day_name() function

I have a data frame with df name : InvoiceNumber ProductCode InvoiceDate UnitPrice CustomerId Country 0 489434 85048 2009-12-01 07:45:00 6.95 13085 United Kingdom 1 489434 79323P 2009-12-01 07:45:00 6.75 13085 United Kingdom 2 489434 79323W 2009-12-01 07:45:00 6.75 13085 United Kingdom 3 489434 22041 2009-12-…

How to loop through a folder in Python

I am a new python user and I am trying to loop through all the items in a set file. Here is my code this far – When I load the for loop without the pd.read_excel it prints the names of each of the sheets in the console yet when I add in the read_excel portion I receive an error

how to load and save pandas data frame to excel .csv file

CODE:- Now when I run the code I am getting this output. How to load this output into the excel as .csv file with the name as ’11-08-2022.csv’. And suppose if I run the code on 12-08-2022 then another .csv file should add in the same folder where first .csv file has saved and now the file name sho…

Vlookup using python when data given in range

I have two excel files, I want to perform vlookup and find difference of costs using python or even excel. My files look like this source_data.xlsx contains contains distance covered and their price, example distance range from 1 to 100 should be charged 4800 and distance range from 101 to 120 should be charg…

Pandas apply same filtering on two dataframes

I have two pandas dataframes with the same indexes and lengths. However, they might contain nans at different places. See, example input below: I want to do some calculations where I want to remove indexes in both the dataframes even if one of them has a NaN values. So, in those case only the first row is val…

Value of column based on value of other column using pandas.apply

I have the following dataframe: index season round number driverId position time 0 1996 1 1 villeneuve 1 1:43.702 1 1996 1 1 damon_hill 2 1:44.243 2 1996 1 1 irvine 3 1:44.981 with df_laps[[‘ms’]] = 0 I can create a new column ms with all rows containing value = 0. index season round number driver…