Skip to content
Advertisement

Tag: pandas

How to convert nested dictionary to levelled Pandas Dataframe

How to convert more than 3 level N nested dictionary to levelled dataframe? what I expect: index level_0 level_1 value 0 .Stock .No_0 3241512 1 .Stock .No_1 1111111111 2 .Stock .No_2 444444444444 3 .Stock .Version 46 4 .Stock .Revision 78 5 .Time NaN 12.11.2022 Firsly I need to convert nested dictionary to list of levelled dictionaries, than lastly convert list

Break line chart on the plot

I have a dataframe with a column for weeks and data captured for each week. it looks like this Now I am plotting a line chart with this data . Notice that from week 23 to week 40, we didnt have data. so my intention is to skip this weeks on the plot and only have a line chart of

Replace span tags with whitespace or parse contents as new column with pandas.read_html

I want to scrape Congressional stock trades from Capitol Trades. I can scrape the data, but the column that contains stock tickers has a span tag that separates company names from company tickers. pandas.read_html() removes this span tag, which concatenates company names and tickers and makes it difficult to recover tickers. For example, company names that end with an “INC”

Pandas: filter on grouped and aggregated dataframe

I have a dataframe which is based on a read-in excel list. The data has multiple columns and rows with one unique identifier. I want to plot the data through a PyQT interface based on some user selection (checkboxes), but I cannot select one unique row for plotting. The data looks like this: After I get this: I can use

pandas split values in column

I’m new to pandas (version 1.1.5) and have tried str.split() and str.extract() to split column POS of numerical values with no success. My dataframe is about 3000 lines and is structured like this (note _ and – delimiters in subset): I would like for the dataframe to look like this (i.e. retain values preceding all delimiters): My attempts have either

using set() with pandas

May I ask you please if we can use set() to read the data in a specific column in pandas? For example, I have the following output from a DataFrame df1: where the first column is the index.. I tried first to isolate the second column using the following: x = pd.DataFrame(df1, coulmn=[0]) Then, I transposed the column using the

Advertisement