Category "pandas"

How to groupby a column but keep all rows as columns

I have a dataframe that was a result of a join operation. This operation had multiple matches, resulting in multiple rows. I want to move resulting match rows t

Python: Formatting a Pandas dataframe head with LaTex

I have made a Pandas dataframe from several NumPy arrays and tried to format columns heads using LaTex, but it looks awful. I'm working with Jupyter Notebook. i

Creating a mean column in a dataframe dependent on other variables of the dataframe in pandas

I have a code that is roughly like this: import numpy as np import pandas as pd df = pd.DataFrame({'Group':['a','a','b','b','b','c','c'], 'Label':[0,1,0,1,1,0,

how to create 3 tables using join in pandas/python?

I need help / guidance with my code below to see if I am doing wrong or what i need to add. I am trying to create three tables using joins in pandas. Can anyone

Simple way to create multiindex columns with pandas

I am sorry for asking but I did not get the still existing answers. I simply glued two data frames with the same column names. | | X | Y | X | Y | |-

module 'numpy' has no attribute 'ndarray'

My Jupiter notebook was crushed, so I have to reinstall the notebook, but in the new Jupiter notebook, I cannot run pandas. import pandas as pd AttributeError

Creating a new dataframe column with the number of overlapping words between dataframe and list

I'm having some trouble fixing the following problem: I have a dataframe with tokenised text on every row that looks (something) like the following index feelin

Plotting subplots of dataframe with subplots of piecharts or nested pie chart with Pandas and Matplotlib

Hi my dataframe looks like the followig format and is named immunizations_df: I'm trying to plot a subplot of piecharts, each piechart symbols the number of va

How to map single column in pandas using multiple columns (text and numbers) in a separate df

I'm trying to convert U.S. geolocation codes for states, counties and cities. The problem is, the county and city codes are duplicated -- meaning, multiple stat

How to select all columns whose names start with X in a pandas DataFrame

I have a DataFrame: import pandas as pd import numpy as np df = pd.DataFrame({'foo.aa': [1, 2.1, np.nan, 4.7, 5.6, 6.8], 'foo.fighters': [0

How to display an error message when pd.read.csv fails

I use pd.read_csv to fetch GCS data. However, when the file size is too large or something, the python task force quit automatically at the line using pd.read_c

Get specific rows which match condition pandas [duplicate]

I have the following dataframe My current code is as follows: Outcome is to only show instances where ImageFileName is services.exe and the P

How to join two very large dataframes together with same columns?

I have two datasets that look like this: df1: Date City State Quantity 2019-01 Chicago IL 35 2019-01 Orlando FL 322 ... .... ... ... 2021-07 Chicago IL 334 202

Get records that are a time interval away from a given date and specific conditions on a pandas DataFrame

Let it be the following Python Panda DataFrame: | ID | date | direction | country_ID | |-----------|-------------------------|----

LabVIEW generated Excel files unable to be read by pandas.read_excel

I'm having an issue when I save LabVIEW outputs as .xlsx files. When I try to import with Pandas I get the following error: expected <class 'openpyxl.styles.

how to get a single value from dataframe only in Python

I have dataframe df_my that looks like this id name age major ---------------------------------------- 0 1 Mark 34 Engli

Python dataframe to Google Sheet: Freeze rows and sketch vertical lines around a sets of columns

I have a dataframe df_final (it is a time series data) as shown in attached photo. I am able to write this dataframe to the Google Sheet using the code below. Q

How can I plot a line chart with two different companies monthly sales from 12 months before and 12 months after

The dataframe is a snapshot of what I'm working with. What I want to achieve is a line chart of the monthly sales of the different brands. Months with '-' befor

Get only those rows from a pandas data frame where a particular value is not present in a data frame column of type list

One of my columns in dataframe is of type list. I want to get only those rows where color is not red.Output should give row 2 and 3. I tried def Removecolo

can i make my scraping (pandas read html) script faster?

i have a very simple script, it just scrapes some tables off the internet and inserts it into a db. however: tickerlist contains about 8000 rows. and the script