id
stringlengths
7
11
source
stringclasses
1 value
category
stringclasses
11 values
title
stringlengths
15
214
text
stringlengths
70
30.5k
url
stringlengths
57
160
tags
stringlengths
3
113
created_at
int64
1.22B
1.79B
se_79963164
stackoverflow
DATA_SCIENCE
How to check if a function is a valid Pandas function string, for use with .agg()
How to check if a function is a valid Pandas function string, for use with .agg() I have a wrapper that ends with a called to pandas.DataFrame.groupby().agg() or pandas.DataFrame.groupby()[colname].agg(). I would like to directly query a pandas module to get the list of string functions, or next best thing would be to...
https://stackoverflow.com/questions/79963164/how-to-check-if-a-function-is-a-valid-pandas-function-string-for-use-with-agg
python, pandas, group-by
1,781,871,685
se_33411055
stackoverflow
DATA_SCIENCE
Use Python pandas to check if columns contain identical values or NaN
Use Python pandas to check if columns contain identical values or NaN I would like a function that returns True if for each row in the columns, they contain only elements that are either the same as the elements in other columns or NaN. Example: A B C 1 1 NaN 4 NaN NaN 2 2 2 The function should return True on...
https://stackoverflow.com/questions/33411055/use-python-pandas-to-check-if-columns-contain-identical-values-or-nan
python, pandas, dataframe, equality
1,446,112,749
se_79963246
stackoverflow
DATA_SCIENCE
What Python packages/libs are your favorite for automating prod level report building (graphs, charts)
What Python packages/libs are your favorite for automating prod level report building (graphs, charts) I realize this is a broad question and will depend case by case. Really just looking to explore new Python libraries and pandas since there are so many out there! My main tasks involve moving data from massive repor...
https://stackoverflow.com/questions/79963246/what-python-packages-libs-are-your-favorite-for-automating-prod-level-report-bui
python, pandas, matplotlib, seaborn, jinja2
1,781,880,902
se_69571972
stackoverflow
DATA_SCIENCE
Extracting Excel sheet's style and applying it on Pandas DataFrame
Extracting Excel sheet's style and applying it on Pandas DataFrame I've been looking around, however, it seems that this question was not asked yet. Is there a way to get Excel's sheet style format and apply it on a Pandas DataFrame, respecing the shape of the DataFrame and replicating completely? Example: Thanks...
https://stackoverflow.com/questions/69571972/extracting-excel-sheets-style-and-applying-it-on-pandas-dataframe
python, pandas, pandas-styles
1,634,219,639
se_25757042
stackoverflow
DATA_SCIENCE
Create hash value for each row of data with selected columns in dataframe in python pandas
Create hash value for each row of data with selected columns in dataframe in python pandas I have asked similar question in R about creating hash value for each row of data. I know that I can use something like hashlib.md5(b'Hello World').hexdigest() to hash a string, but how about a row in a dataframe? update 01 I ...
https://stackoverflow.com/questions/25757042/create-hash-value-for-each-row-of-data-with-selected-columns-in-dataframe-in-pyt
python, hash, pandas
1,410,321,200
se_69180094
stackoverflow
DATA_SCIENCE
Regular expression (^|[^A-Za-z0-9])Trump([^A-Za-z0-9]|$) meaning
Regular expression (^|[^A-Za-z0-9])Trump([^A-Za-z0-9]|$) meaning Given a tweet dataset from this link which has a content column as follows: I hope to add one new column to identify whether or not the tweet mentioned Trump. The regex patern (^|[^A-Za-z0-9])Trump([^A-Za-z0-9]|$) seems work out, but I don't understand w...
https://stackoverflow.com/questions/69180094/regular-expression-a-za-z0-9trumpa-za-z0-9-meaning
python-3.x, regex, pandas, string, python-re
1,631,631,305
se_40914354
stackoverflow
DATA_SCIENCE
Get first row given by a column value in pandas
Get first row given by a column value in pandas How can I get the first row given by a column value? For example, I have the dataframe below: >>> df 0 1 1 1 2 1 3 2 4 2 I want to get the first row where 2 appears. In this example the row is: 3 2 Note that there is no column name in the dataframe. I am a n...
https://stackoverflow.com/questions/40914354/get-first-row-given-by-a-column-value-in-pandas
python, pandas, dataframe
1,480,605,802
se_54336413
stackoverflow
DATA_SCIENCE
Insert new column in DataFrame with diff from previous row?
Insert new column in DataFrame with diff from previous row? I have a Pandas DataFrame with a dataset, which is looking like this: floor_temperature power_consumption outside_temperature timestamp 2019-01-23 00:00:00+00:00 8.300000 0.022000 -11.393333 2019-01-2...
https://stackoverflow.com/questions/54336413/insert-new-column-in-dataframe-with-diff-from-previous-row
python, pandas
1,548,281,139
se_59269992
stackoverflow
DATA_SCIENCE
Merging several xlsx files into one
Merging several xlsx files into one In a directory, I have several xlsx files, and I would like to put them in one single xlsx file. So I did this code: all_data=pd.DataFrame() for item_excell in arr2: if item_excell.endswith('.xlsx'): df=pd.read_excel(item_excell) all_data=all_data.append(df, ig...
https://stackoverflow.com/questions/59269992/merging-several-xlsx-files-into-one
python, pandas
1,575,989,713
se_76173731
stackoverflow
DATA_SCIENCE
How to convert this nested JSON into an Excel or CSV file using Python
How to convert this nested JSON into an Excel or CSV file using Python So I have this nested json and I'm struggling with the conversion into a tabular form because of how it's shaped, it could become a .xslx or .csv. I tried doing it like this but I didn't work. # Load the JSON data into a pandas DataFrame df = pd.re...
https://stackoverflow.com/questions/76173731/how-to-convert-this-nested-json-into-an-excel-or-csv-file-using-python
python, json, pandas, export-to-csv
1,683,206,752
se_79960825
stackoverflow
DATA_SCIENCE
Unexpected duplicates after pd.pivot_table
Unexpected duplicates after pd.pivot_table I have a data set that looks like this: >>> df_anon.head() a b c d 0 1 30 1 929.3453 1 1 30 3 875.3986 2 1 30 5 849.9972 3 1 51 1 571.8364 4 1 51 2 508.9944 >>> df_anon[["a", "b", "c"]].nunique() a 16665 b 61 c 6 d...
https://stackoverflow.com/questions/79960825/unexpected-duplicates-after-pd-pivot-table
python, pandas, dataframe, pivot-table
1,781,634,925
se_42010398
stackoverflow
DATA_SCIENCE
Most Effecient way to parse Evtx files for specific content
Most Effecient way to parse Evtx files for specific content I have hundreds of gigs of Evtx security event logs I want to parse for specific Event IDs (4624) and usernames (joe) based on the Event IDs. I have attempted to use Powershell cmdlet like below: get-winevent -filterhashtable @{Path="mypath.evtx"; providerna...
https://stackoverflow.com/questions/42010398/most-effecient-way-to-parse-evtx-files-for-specific-content
python, windows, powershell, pandas
1,486,062,497
se_79926894
stackoverflow
DATA_SCIENCE
python pandas value from prior row - shift
python pandas value from prior row - shift I received a list from a user that needs to be reformatted. I need to pluck data out of prior rows. The Make/Model column contains two different kinds of data. I need to add the Make to the Model rows. This code only adds the Make to the first row of the models. I know I am ...
https://stackoverflow.com/questions/79926894/python-pandas-value-from-prior-row-shift
python, pandas
1,776,367,923
se_77969964
stackoverflow
DATA_SCIENCE
Deprecation Warning with groupby.apply
Deprecation Warning with groupby.apply I have a python script that reads in data from a csv file The code runs fine, but everytime it runs I get this Deprecation message: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grou...
https://stackoverflow.com/questions/77969964/deprecation-warning-with-groupby-apply
python, pandas, dataframe
1,707,501,046
se_79499286
stackoverflow
DATA_SCIENCE
pandas dataframe select rows with ternary operator
pandas dataframe select rows with ternary operator My requirement is simple, I need to select the rows from a Pandas DataFrame when one of two couple columns are populated or both. The attributes contain integer foreign keys. This works: df_ofComment = df_obsFinding.loc[ (None if df_obsFinding['Comments'] is Non...
https://stackoverflow.com/questions/79499286/pandas-dataframe-select-rows-with-ternary-operator
pandas, dataframe, conditional-operator
1,741,645,645
se_20091077
stackoverflow
DATA_SCIENCE
deque in python pandas
deque in python pandas I am using Python's deque() to implement a simple circular buffer: from collections import deque import numpy as np test_sequence = np.array(range(100)*2).reshape(100,2) mybuffer = deque(np.zeros(20).reshape((10, 2))) for i in test_sequence: mybuffer.popleft() mybuffer.append(i) ...
https://stackoverflow.com/questions/20091077/deque-in-python-pandas
python, pandas, buffer
1,384,937,032
se_79432928
stackoverflow
DATA_SCIENCE
Handling bad lines when reading csv files with pd.read_csv()
Handling bad lines when reading csv files with pd.read_csv() I am trying to parse some csv files with a few thousand rows. The csv is structured with comma as a delimiter and quotation marks enclosing each field. I want to use pd.read_csv() to parse the data without skipping the faulty lines with on_bad_line='pass' ar...
https://stackoverflow.com/questions/79432928/handling-bad-lines-when-reading-csv-files-with-pd-read-csv
python, pandas, csv, error-handling, read-csv
1,739,360,620
se_57747894
stackoverflow
DATA_SCIENCE
What exactly is passed to groupby.apply in pandas?
What exactly is passed to groupby.apply in pandas? I'm trying to understand how the pandas groupby and apply methods work. I found this simple example, which I paste below: import pandas as pd ipl_data = {'Team': ['Riders', 'Riders', 'Devils', 'Devils', 'Kings', 'kings', 'Kings', 'Kings', 'Riders', 'Royals', 'Roya...
https://stackoverflow.com/questions/57747894/what-exactly-is-passed-to-groupby-apply-in-pandas
python, pandas, dataframe, group-by, pandas-apply
1,567,356,973
se_59782986
stackoverflow
DATA_SCIENCE
How to use column names with spaces in NamedAgg expressions
How to use column names with spaces in NamedAgg expressions Is it possible to create names with spaces and special characters when naming an aggregation column using pandas.NamedAgg aggregation function? The typical syntax would be: pvt = (df.groupby(by=[....]) .agg(value=pd.NamedAgg(column='col', aggfunc='c...
https://stackoverflow.com/questions/59782986/how-to-use-column-names-with-spaces-in-namedagg-expressions
pandas, group-by
1,579,246,553
se_79957069
stackoverflow
DATA_SCIENCE
Counting items in column or why is my code only counting one item in the string?
Counting items in column or why is my code only counting one item in the string? A continuation of yesterday's question. I need to count how many times a word (gene name) appears on a row (bacterial sample). I needed to see how many double-copied genes there are. Since yesterday, I decided to combine all columns that ...
https://stackoverflow.com/questions/79957069/counting-items-in-column-or-why-is-my-code-only-counting-one-item-in-the-string
python, pandas
1,781,263,331
se_9826431
stackoverflow
DATA_SCIENCE
Fast insertion of pandas DataFrame into Postgres DB using psycopg2
Fast insertion of pandas DataFrame into Postgres DB using psycopg2 I am trying to insert a pandas DataFrame into a Postgresql DB (9.1) in the most efficient way (using Python 2.7). Using "cursor.execute_many" is really slow, so is "DataFrame.to_csv(buffer,...)" together with "copy_from". I found an already much! faste...
https://stackoverflow.com/questions/9826431/fast-insertion-of-pandas-dataframe-into-postgres-db-using-psycopg2
python, postgresql, psycopg2, pandas
1,332,433,402
se_54494167
stackoverflow
DATA_SCIENCE
How to merge on approximate strings?
How to merge on approximate strings? I would like to merge 2 Data Frames on approximate country name with merge as of but i am getting the following error: TypeError:'NoneType' object is not callable Please see the illustrative code below: cl = {'Country' : ["Brazil", "US", "Russia"], 'BL?':['No', 'No','Yes']} cli...
https://stackoverflow.com/questions/54494167/how-to-merge-on-approximate-strings
python, pandas
1,549,119,093
se_46068769
stackoverflow
DATA_SCIENCE
Export dataframe in pyspark to excel file given the 'openpyxl' module is not installed
Export dataframe in pyspark to excel file given the 'openpyxl' module is not installed I am trying to write my spark dataframes in an excel file to generate desired reports by changing them in pandas dataframe and then using panda_df = df.toPandas() writer = pd.ExcelWriter(filename) panda_df.to_excel(writer,...
https://stackoverflow.com/questions/46068769/export-dataframe-in-pyspark-to-excel-file-given-the-openpyxl-module-is-not-ins
python, excel, pandas, pyspark, apache-spark-sql
1,504,681,171
se_35605042
stackoverflow
DATA_SCIENCE
Handle Nan when using Pandas ExcelWriter in python
Handle Nan when using Pandas ExcelWriter in python How would I change the following code to handle NaN values as just empty cells within my dataframe as I iterate through it line by line outputting values in column A? excel = pd.ExcelWriter(f_name,engine='xlsxwriter') wb = excel.book ws = wb.add_worksheet('PnL') for...
https://stackoverflow.com/questions/35605042/handle-nan-when-using-pandas-excelwriter-in-python
python, pandas, nan, xlsxwriter, spreadsheet-excel-writer
1,456,324,578
se_79951961
stackoverflow
DATA_SCIENCE
python dataframe rolling by date to get sum and concatinate a string
python dataframe rolling by date to get sum and concatinate a string I need to sum up transaction amounts over a rolling period and concat the transaction ids that make up the total. Full code is at the bottom. The below statements return the expected results. rollingSum = df.groupby( ["EMPLOYEE ID", "ACCOUNT EMAI...
https://stackoverflow.com/questions/79951961/python-dataframe-rolling-by-date-to-get-sum-and-concatinate-a-string
python, pandas, dataframe
1,780,677,371
se_78459145
stackoverflow
DATA_SCIENCE
How can I prevent NaN error when fitting data, and what is the best way to do so without skewing data?
How can I prevent NaN error when fitting data, and what is the best way to do so without skewing data? #Load weather data data = pd.read_csv(r"C:\Users\slick\Downloads\weather_dataset.csv") #Hot encode data, for columns with information that is not df_weather_processed = pd.get_dummies(data, columns=['Location','Rai...
https://stackoverflow.com/questions/78459145/how-can-i-prevent-nan-error-when-fitting-data-and-what-is-the-best-way-to-do-so
python, pandas, dataset, knn, data-fitting
1,715,332,829
se_29672674
stackoverflow
DATA_SCIENCE
Python pandas: equivalent to SQL's aggregate functions?
Python pandas: equivalent to SQL's aggregate functions? What is the pandas equivalent of something like: select mykey, sum(Field1) as Field1, avg(Field1) as avg_field1, min(field2) as min_field2 from df group by mykey in SQL? I understand that in pandas I can do grouped = df.groupby('mykey') and then grouped.me...
https://stackoverflow.com/questions/29672674/python-pandas-equivalent-to-sqls-aggregate-functions
python, sql, pandas
1,429,181,939
se_79952620
stackoverflow
DATA_SCIENCE
Replacing xls file input with txt input
Replacing xls file input with txt input I have some code suitable for .xls file handling. But the input files are not consistent. If I use .txt files as input the problem maybe solved. I need some sample code for the same functionality. xls_file_link txt_file_link The below code works for .xls file input: import panda...
https://stackoverflow.com/questions/79952620/replacing-xls-file-input-with-txt-input
python, pandas, dataframe, file-handling
1,780,833,528
se_79951136
stackoverflow
DATA_SCIENCE
DolphinDB Python API: __DolphinDB_Type__ triggers Pandas UserWarning
DolphinDB Python API: __DolphinDB_Type__ triggers Pandas UserWarning I'm using the DolphinDB Python API to upload a pandas DataFrame and want to control the DolphinDB column types, for example trade_time as DATETIME instead of the default STRING. Here's what I'm doing: import pandas as pd import dolphindb as ddb s = ...
https://stackoverflow.com/questions/79951136/dolphindb-python-api-dolphindb-type-triggers-pandas-userwarning
python, pandas, dataframe, dolphindb
1,780,535,719
se_44424659
stackoverflow
DATA_SCIENCE
Writing to an existing Excel Workbook using xlwings
Writing to an existing Excel Workbook using xlwings I am new to Python and working on a project that I could use some help on. So I am trying to modify an existing excel workbook in order to compare stock data. Luckily, there was a program online that retrieved all the data I need and I have successful been able to ...
https://stackoverflow.com/questions/44424659/writing-to-an-existing-excel-workbook-using-xlwings
python, excel, pandas, overwrite, xlwings
1,496,880,758
se_66431667
stackoverflow
DATA_SCIENCE
How to get max value AND respective column name with pandas dataframe
How to get max value AND respective column name with pandas dataframe I have a df that looks something like this, but with a lot more columns Item Raw Juice Jelly Apples 2 5 3 Grapes 1 3 4 Bananas 7 3 5 So far I was trying to create two new columns, one with hi...
https://stackoverflow.com/questions/66431667/how-to-get-max-value-and-respective-column-name-with-pandas-dataframe
python, pandas, dataframe
1,614,645,420
se_79927488
stackoverflow
DATA_SCIENCE
How to preserve grouping cols in Pandas without brittle workarounds
How to preserve grouping cols in Pandas without brittle workarounds I'm trying to understand the new behavior of .groupby in pandas My complaint is two-fold: that .groupby doesn't allow you to access the cols you grouped on by name unless you do something brittle like group.name[0] That when the dataset is put back ...
https://stackoverflow.com/questions/79927488/how-to-preserve-grouping-cols-in-pandas-without-brittle-workarounds
python, pandas, dataframe, group-by
1,776,439,554
se_79950925
stackoverflow
DATA_SCIENCE
How to avoid iterrows() for string concatenation and One-Hot Encoding in Pandas?
How to avoid iterrows() for string concatenation and One-Hot Encoding in Pandas? I am a university freshman learning AI, and we are currently working on a Kaggle dataset. I need to concatenate two string columns (ColA and ColB) and then convert the result into One-Hot Encoding. Currently, I am using a for loop with it...
https://stackoverflow.com/questions/79950925/how-to-avoid-iterrows-for-string-concatenation-and-one-hot-encoding-in-pandas
python, pandas, dataframe, performance
1,780,500,262
se_79948413
stackoverflow
DATA_SCIENCE
Extract data from a line graph
Extract data from a line graph I want to convert the information on a graph/chart to a tabular form. Table contains divisions from x axis and their corresponding values. The graph is line graph and scale is linear. i have achieved pixel to values. i want to remove unwanted characters/lines/symbols/noise from the image...
https://stackoverflow.com/questions/79948413/extract-data-from-a-line-graph
python, pandas, image-processing, ocr, pixel
1,780,052,754
se_79949942
stackoverflow
DATA_SCIENCE
Pandas rolling window with step equal to window size
Pandas rolling window with step equal to window size I searched how to use the rolling function from Pandas, but struggle using it. Let's take a simple example: [0, 1, 2, ..., 15] as a Pandas series. s = pd.Series(range(16)) I want to obtain the sum of the first four elements, then the sum of the next four, until rea...
https://stackoverflow.com/questions/79949942/pandas-rolling-window-with-step-equal-to-window-size
python, pandas
1,780,356,993
se_56778067
stackoverflow
DATA_SCIENCE
How are pandas data frames stored in memory?
How are pandas data frames stored in memory? In particular, when I create a DataFrame by concatenating two Pandas Series objects, does Python create a new memory location and store copies of the series', or does it just create references to the two series? If it just makes references, then would modifying the series ...
https://stackoverflow.com/questions/56778067/how-are-pandas-data-frames-stored-in-memory
python, pandas
1,561,569,492
se_79950340
stackoverflow
DATA_SCIENCE
Best practice to map extracted DataFrames or text back to original HTML elements
Best practice to map extracted DataFrames or text back to original HTML elements I am processing HTML files and extracting data from them. Tables are extracted using pandas.read_html(), and plain text is extracted using BeautifulSoup (via get_text(separator=...)). And these dfs/strings are then passed to some extracti...
https://stackoverflow.com/questions/79950340/best-practice-to-map-extracted-dataframes-or-text-back-to-original-html-elements
python, html, pandas, beautifulsoup
1,780,412,674
se_57595661
stackoverflow
DATA_SCIENCE
Non-overlapping rolling windows in pandas dataframes
Non-overlapping rolling windows in pandas dataframes I am familiar with the Pandas Rolling window functions, but they always have a step size of 1. I want to do a moving aggregate function in Pandas, but where the entries don't overlap. In this Dataframe: device_id 490041 519 567393 566 438745 727 13...
https://stackoverflow.com/questions/57595661/non-overlapping-rolling-windows-in-pandas-dataframes
python, pandas, dataframe
1,566,404,055
se_79933604
stackoverflow
DATA_SCIENCE
Fusing row with previous row(s) depending on criteria
Fusing row with previous row(s) depending on criteria I'm trying to fix a CSV file I received in which actual new lines were inserted throughout the data, effectively splitting one row of data into multiple ones with incomplete columns. The line breaks are placed instead of a blank space after a completed word. Due to...
https://stackoverflow.com/questions/79933604/fusing-row-with-previous-rows-depending-on-criteria
python, pandas, dataframe, csv
1,777,460,450
se_15315452
stackoverflow
DATA_SCIENCE
Selecting with complex criteria from pandas.DataFrame
Selecting with complex criteria from pandas.DataFrame For example I have simple DF: import pandas as pd from random import randint df = pd.DataFrame({'A': [randint(1, 9) for x in range(10)], 'B': [randint(1, 9)*10 for x in range(10)], 'C': [randint(1, 9)*100 for x in range(10)]})...
https://stackoverflow.com/questions/15315452/selecting-with-complex-criteria-from-pandas-dataframe
python, pandas, select, filter, conditional-statements
1,362,860,269
se_65746665
stackoverflow
DATA_SCIENCE
Plotting multiple pie charts in a single figure
Plotting multiple pie charts in a single figure these are my columns: SeniorCitizen Partner Dependent Yes Yes No No Yes No No No Yes Yes No No I wanted to plot separate pie charts of all these columns in a single figure or sheet. This is my...
https://stackoverflow.com/questions/65746665/plotting-multiple-pie-charts-in-a-single-figure
python, pandas, matplotlib, jupyter-notebook
1,610,773,741
se_79720739
stackoverflow
DATA_SCIENCE
How to merge two CSV files based on matching values in different columns and keep unmatched rows with placeholders?
How to merge two CSV files based on matching values in different columns and keep unmatched rows with placeholders? I'm working on a data cleaning task and could use some help. I have two CSV files with thousands of rows each: File A contains product shipment records. File B contains product descriptions and categorie...
https://stackoverflow.com/questions/79720739/how-to-merge-two-csv-files-based-on-matching-values-in-different-columns-and-kee
python, pandas, csv, awk, data-cleaning
1,753,932,319
se_69154946
stackoverflow
DATA_SCIENCE
Fill nan gaps in pandas df only if gaps smaller than N nans
Fill nan gaps in pandas df only if gaps smaller than N nans I am working with a pandas data frame that contains also nan values. I want to substitute the nans with interpolated values with df.interpolate, but only if the length of the sequence of nan values is =<N. As an example, let's assume that I choose N = 2 (so I...
https://stackoverflow.com/questions/69154946/fill-nan-gaps-in-pandas-df-only-if-gaps-smaller-than-n-nans
python, pandas, dataframe, interpolation, nan
1,631,478,155
se_70638187
stackoverflow
DATA_SCIENCE
How to sort all the 1500 rational numbers (which are in the two unequal rows in an Excel sheet) using pandas?
How to sort all the 1500 rational numbers (which are in the two unequal rows in an Excel sheet) using pandas? I have 100 Excel files, each containing 1500 rational numbers which have no column titles. In each file, the first row contains 1000 numbers, and the second row contains 500 numbers. First I want to sort all t...
https://stackoverflow.com/questions/70638187/how-to-sort-all-the-1500-rational-numbers-which-are-in-the-two-unequal-rows-in
python, excel, pandas, dataframe, sorting
1,641,698,510
se_73581638
stackoverflow
DATA_SCIENCE
How to convert columns (pandas dataframe) into row for SQL insertion?
How to convert columns (pandas dataframe) into row for SQL insertion? I have a table QUESTIONNAIRE that looks like this: The columns EXT1, EXT2, ... are the question's code; the value is the answer for the question. I have 10000 QuestionnaireID and 50 Question's codes. I would like to add this into a new table called...
https://stackoverflow.com/questions/73581638/how-to-convert-columns-pandas-dataframe-into-row-for-sql-insertion
python, pandas, sqlite, dataset
1,662,116,918
se_71029155
stackoverflow
DATA_SCIENCE
How create a dataframe from list of dictionary of multi-level JSON
How create a dataframe from list of dictionary of multi-level JSON I have a JSON file that has multiple levels. By using Pandas, I can read the first level and put it in a dataframe. However, as you can see in this dataframe, the second level is inside a column which has format of list of dictionary. How can I covert ...
https://stackoverflow.com/questions/71029155/how-create-a-dataframe-from-list-of-dictionary-of-multi-level-json
python, pandas, dataframe, dictionary
1,644,299,681
se_67050945
stackoverflow
DATA_SCIENCE
P-Value to test hypothesis shows NaN
P-Value to test hypothesis shows NaN I am getting NaN for p.value when trying to test the null hypothesis that the mean of the revenue for the phone plan surf is the same as that of the ultimate plan. I don't understand what I am doing wrong. I'm assuming that it may have to do with my DataFrame call_plan_merge. There...
https://stackoverflow.com/questions/67050945/p-value-to-test-hypothesis-shows-nan
python, pandas, dataframe, scipy, hypothesis-test
1,618,182,264
se_49731494
stackoverflow
DATA_SCIENCE
Histogram of a dataframe - How do I put index as X-axis and show plot?
Histogram of a dataframe - How do I put index as X-axis and show plot? I have a data frame as follows: 0 1 2 3 4 5 6 7 8 9 A 1 1 1 2 3 4 5 6 6 7 B 2 3 4 5 7 9 11 14 15 17 C 1 1 2 3 4 5 7 8 9 11 D 2 3 4 5 6 8 9 11 13 15 I am trying to plot a histogram from it such that the letters {A,B,C,D} are in the ...
https://stackoverflow.com/questions/49731494/histogram-of-a-dataframe-how-do-i-put-index-as-x-axis-and-show-plot
python, pandas, dataframe, histogram
1,523,272,011
se_63776791
stackoverflow
DATA_SCIENCE
how to add background color tospecific dataframe column while converting to html
how to add background color tospecific dataframe column while converting to html I need to colour a column with different colours. I'm using the below code but it's not working getting data in mail with straight line. The HTML method is working to generate the table, but I need a different colour to all column in Data...
https://stackoverflow.com/questions/63776791/how-to-add-background-color-tospecific-dataframe-column-while-converting-to-html
python, html, pandas, dataframe, pdf
1,599,478,417
se_64904147
stackoverflow
DATA_SCIENCE
Pandas dataframe.to_html() - edit text color and add background color of header columns
Pandas dataframe.to_html() - edit text color and add background color of header columns I am exporting a pandas dataframe as an html table and have been playing around with styling the the header columns in the final table. Here is an example dataframe I have generated: x = np.arange(0,100,5) y = np.arange(0,20,1) ex...
https://stackoverflow.com/questions/64904147/pandas-dataframe-to-html-edit-text-color-and-add-background-color-of-header
python, html, pandas, pdf
1,605,750,176
se_74995884
stackoverflow
DATA_SCIENCE
Pandas Python 3.11 Pivot FutureWarning: default value of of numeric_only in DataFrameGroupBy.sum is depricated
Pandas Python 3.11 Pivot FutureWarning: default value of of numeric_only in DataFrameGroupBy.sum is depricated Have a large mixed table of text and numbers and am pivoting a smaller set from the larger table. It appears that when I updated to Python 3.11 I'm receiving an FutureWarning on my pivots now. df = df.pivot_...
https://stackoverflow.com/questions/74995884/pandas-python-3-11-pivot-futurewarning-default-value-of-of-numeric-only-in-data
pandas, pivot, python-3.11
1,672,762,554
se_12433076
stackoverflow
DATA_SCIENCE
Download history stock prices automatically from yahoo finance in python
Download history stock prices automatically from yahoo finance in python Is there a way to automatically download historical prices of stocks from yahoo finance or google finance (csv format)? Preferably in Python.
https://stackoverflow.com/questions/12433076/download-history-stock-prices-automatically-from-yahoo-finance-in-python
pandas, finance, yahoo-finance, google-finance, stockquotes
1,347,663,975
se_79943881
stackoverflow
DATA_SCIENCE
How to incrementally merge daily CSV delta updates into a master file without losing expired records?
How to incrementally merge daily CSV delta updates into a master file without losing expired records? I am building a data pipeline to create a cumulative master dataset from daily CSV exports generated by a booking system. Context & Data Structure Source: A daily CSV file containing status transitions for bookings. ...
https://stackoverflow.com/questions/79943881/how-to-incrementally-merge-daily-csv-delta-updates-into-a-master-file-without-lo
python, pandas, csv, data-handling, incremental-load
1,779,263,402
se_79946020
stackoverflow
DATA_SCIENCE
Pandera.Column(bool, nullable=True) fails to validate a column with None values
Pandera.Column(bool, nullable=True) fails to validate a column with None values I'm trying to validate a pandas DataFrame where one column is boolean but may have nulls. I followed the pandera docs and set nullable=True: import pandas as pd import pandera.pandas as pa schema = pa.DataFrameSchema({"x": pa.Column(bool,...
https://stackoverflow.com/questions/79946020/pandera-columnbool-nullable-true-fails-to-validate-a-column-with-none-values
python, pandas, pandera
1,779,661,753
se_38435395
stackoverflow
DATA_SCIENCE
Python: How to display a dataframe using Tkinter
Python: How to display a dataframe using Tkinter I am new to Tkinter. I have tried a few widgets provided by Tkinter but cannot find a suitable way to display a dataframe. I tried Tkinter.Text. I used update() instead of mainloop() because I would like to update df and display again. mainloop() will block my program...
https://stackoverflow.com/questions/38435395/python-how-to-display-a-dataframe-using-tkinter
python, pandas, dataframe, tkinter
1,468,840,790
se_75836539
stackoverflow
DATA_SCIENCE
Applying conditions to dataframe based on columns specified in a list
Applying conditions to dataframe based on columns specified in a list I have the sample df as follows: df = pd.DataFrame({'weight':[10,20,30,40,50], 'speed':[100,120,140,160,180], 'distance':[1000,1100,1200,1300,1400], 'cat':['Y','N','N','N','Y']}) And I am applying the...
https://stackoverflow.com/questions/75836539/applying-conditions-to-dataframe-based-on-columns-specified-in-a-list
python, pandas, numpy
1,679,678,120
se_63236080
stackoverflow
DATA_SCIENCE
Replace the column values based on the list of dictionary and specific date condition - use if and for loop - Pandas
Replace the column values based on the list of dictionary and specific date condition - use if and for loop - Pandas I have a df and list of dictionary as shown below. df: Date Tea_Good Tea_bad coffee_good coffee_bad 2020-02-01 3 1 10 7 ...
https://stackoverflow.com/questions/63236080/replace-the-column-values-based-on-the-list-of-dictionary-and-specific-date-cond
python-3.x, pandas, dataframe, if-statement
1,596,484,318
se_55744015
stackoverflow
DATA_SCIENCE
.iloc &amp; fillna - inplace=True vs inplace=False
.iloc &amp; fillna - inplace=True vs inplace=False Just out of curiosity I would like to have a quick explanation of the following "issue". When I did this: data_ogd.iloc[:, 3:10].fillna(value=0, inplace=True) nothing changed at my dataframe columns and I still had the NAs at these columns. But when I did this: ...
https://stackoverflow.com/questions/55744015/iloc-fillna-inplace-true-vs-inplace-false
python, pandas
1,555,582,984
se_70382565
stackoverflow
DATA_SCIENCE
IndexError when I added another .groupby() with pandas
IndexError when I added another .groupby() with pandas I get an IndexError when I added this line into my code df['Weekly Hours'] = df.groupby(['Full Name'])['Hours'].agg(sum) I'm trying to figure out how many hours each person has worked with the daily hours I'm provided with. I have to use this code as I'm trying t...
https://stackoverflow.com/questions/70382565/indexerror-when-i-added-another-groupby-with-pandas
python, pandas
1,639,672,575
se_71287630
stackoverflow
DATA_SCIENCE
How do I get tqdm working on pandas apply?
How do I get tqdm working on pandas apply? Tqdm documentation shows an example of tqdm working on pandas apply using progress_apply. I adapted the following code from here https://tqdm.github.io/docs/tqdm/ on a process that regularly take several minutes to perform (func1 is a regex function). from tqdm import tqdm tq...
https://stackoverflow.com/questions/71287630/how-do-i-get-tqdm-working-on-pandas-apply
python, pandas, tqdm
1,645,988,166
se_23162472
stackoverflow
DATA_SCIENCE
Python Pandas daily average
Python Pandas daily average I'm having problems getting the daily average in a Pandas database. I've checked here Calculating daily average from irregular time series using pandas and it doesn't help. csv files look like this: Date/Time,Value 12/08/13 12:00:01,5.553 12/08/13 12:30:01,2.604 12/08/13 13:00:01,2.604 12/0...
https://stackoverflow.com/questions/23162472/python-pandas-daily-average
python, pandas
1,397,855,716
se_66505026
stackoverflow
DATA_SCIENCE
How to solve type object &#39;Series&#39; has no attribute &#39;_get_dtypes&#39; error using modin.pandas?
How to solve type object &#39;Series&#39; has no attribute &#39;_get_dtypes&#39; error using modin.pandas? I am using modin.pandas to remove the duplicates from a dataframe. import modin.pandas as pd import json, ast df = pd.DataFrame(columns=['contact_id', 'test_id']) df['test_id'] = df['test_id'].astype(str) # Cov...
https://stackoverflow.com/questions/66505026/how-to-solve-type-object-series-has-no-attribute-get-dtypes-error-using-mod
python, pandas, dataframe, modin
1,615,029,092
se_41580249
stackoverflow
DATA_SCIENCE
Merged (inner join) data frame has more rows than the original ones
Merged (inner join) data frame has more rows than the original ones I am trying to merge two data frame like below: df_A.shape (204479, 2) df_B.shape (178, 3) new_df = pd.merge(df_A, df_B, how='inner', on='my_icon_number') new_df.shape (266788, 4) I thought the new_df merged above should have fewer rows than df_A ...
https://stackoverflow.com/questions/41580249/merged-inner-join-data-frame-has-more-rows-than-the-original-ones
python, pandas, dataframe
1,484,090,773
se_71311260
stackoverflow
DATA_SCIENCE
Using categorical data for histogram
Using categorical data for histogram Couldn't find the answer elsewhere. Background: I have data from the Business Dynamics Survey, a dataset that aggregates information on firms by firms' characteristics. I am trying to approximate the firms size distribution. Now, the data features 10 firm size categories, the corre...
https://stackoverflow.com/questions/71311260/using-categorical-data-for-histogram
python, pandas, matplotlib, histogram, kernel-density
1,646,150,441
se_59700493
stackoverflow
DATA_SCIENCE
raise ValueError(&quot;Cannot convert {0!r} to Excel&quot;.format(value))
raise ValueError(&quot;Cannot convert {0!r} to Excel&quot;.format(value)) I am trying to use the df.dropna function and I want to nest it multiple times using and by the sign ',' and or by using the sign '|' according to the docs. In my code I am converting a csv file into pandas then I am adjusting the data in the co...
https://stackoverflow.com/questions/59700493/raise-valueerrorcannot-convert-0r-to-excel-formatvalue
python, pandas, spyder
1,578,796,667
se_78340893
stackoverflow
DATA_SCIENCE
How can I pass a variable from CSV file to Oracle SQL query fetch in Python?
How can I pass a variable from CSV file to Oracle SQL query fetch in Python? I have the following piece of code where I read a csv file and connect to the database. then I want to pass two columns from CSV file as variable to my query and eventually convert the result to a pd database. I have tried different ways of b...
https://stackoverflow.com/questions/78340893/how-can-i-pass-a-variable-from-csv-file-to-oracle-sql-query-fetch-in-python
python, pandas, oracle-database, python-oracledb
1,713,356,107
se_64152343
stackoverflow
DATA_SCIENCE
Convert excel to parquet file
Convert excel to parquet file I have a big excel file with some columns containing free text data which have long sentences. I have to convert this into parquet format to ingest into warehouse. I cannot convert it into csv because those columns having long sentences have comma.Tab-delimited is also not working. Any su...
https://stackoverflow.com/questions/64152343/convert-excel-to-parquet-file
python, excel, pandas, dataframe, parquet
1,601,543,748
se_79937863
stackoverflow
DATA_SCIENCE
Using pandas shift and rolling for ML model
Using pandas shift and rolling for ML model I'm building a Machine Learning program to predict football games. One of the features I want to use to train the program are the average goals scored by the team during the last 5 games. I have a pandas DataFrame that, amongst other things, contains this information. When I...
https://stackoverflow.com/questions/79937863/using-pandas-shift-and-rolling-for-ml-model
python, pandas
1,778,207,136
se_62364735
stackoverflow
DATA_SCIENCE
How to fix TypeError: data type not understood with a datetime object in Pandas
How to fix TypeError: data type not understood with a datetime object in Pandas I am working with a date column in pandas. I have a date column. I want to have just the year and month as a separate column. I achieved that by: df1["month"] = pd.to_datetime(Table_A_df['date']).dt.to_period('M') Printing it looks li...
https://stackoverflow.com/questions/62364735/how-to-fix-typeerror-data-type-not-understood-with-a-datetime-object-in-pandas
python, python-3.x, pandas, dataframe, datetime
1,592,076,995
se_79939849
stackoverflow
DATA_SCIENCE
Why does my pandas groupby() result not show total sales by product correctly?
Why does my pandas groupby() result not show total sales by product correctly? I have a DataFrame with three columns: product, quantity, and price. I want to create a new column called sales, then group the data by product and calculate the total sales for each product. Here is my code: import pandas as pd df = pd.Da...
https://stackoverflow.com/questions/79939849/why-does-my-pandas-groupby-result-not-show-total-sales-by-product-correctly
python, pandas, group-by
1,778,578,265
se_79942986
stackoverflow
DATA_SCIENCE
Pivot a DataFrame to include header name
Pivot a DataFrame to include header name Trying to import an Excel sheet where each Product an enterprise sells is specified, along with what company sell its. Every company does not sell every product. The data looks like this: Product Supplier Company1 Company2 0 1 1 x NaN 1 2 ...
https://stackoverflow.com/questions/79942986/pivot-a-dataframe-to-include-header-name
python, pandas
1,779,108,314
se_40660088
stackoverflow
DATA_SCIENCE
Get first row of dataframe in Pandas based on criteria
Get first row of dataframe in Pandas based on criteria Let's say that I have a DataFrame like this one A B C 0 1 2 1 1 1 3 2 2 4 6 3 3 4 3 4 4 5 4 5 The original DataFrame is more complicated with more columns and rows. I want to get the first row that fulfills some criteria. Examples: Get first ...
https://stackoverflow.com/questions/40660088/get-first-row-of-dataframe-in-pandas-based-on-criteria
python, pandas
1,479,400,024
se_79937978
stackoverflow
DATA_SCIENCE
Flask: Dynamically update HTML view when Excel data changes (reload-based, no JS polling)
Flask: Dynamically update HTML view when Excel data changes (reload-based, no JS polling) I am building a small Flask web application that reads process step data from an Excel file and renders it into an HTML page using Jinja2 templates. The Excel file is used as a configuration/definition file: - Each row represents...
https://stackoverflow.com/questions/79937978/flask-dynamically-update-html-view-when-excel-data-changes-reload-based-no-js
python, excel, pandas, flask, web-applications
1,778,228,161
se_50931697
stackoverflow
DATA_SCIENCE
Undo a change that was performed using Pandas
Undo a change that was performed using Pandas I would like to know if there's a technique to simply undo a change that was done using Pandas. For example, I did a string replacement on a few thousand rows of Pandas Dataframe, where, every occurrence of "&" in its string be replaced with "and". However after performi...
https://stackoverflow.com/questions/50931697/undo-a-change-that-was-performed-using-pandas
python, pandas
1,529,421,044
se_16782323
stackoverflow
DATA_SCIENCE
Keep selected column as DataFrame instead of Series
Keep selected column as DataFrame instead of Series When selecting a single column from a pandas DataFrame(say df.iloc[:, 0], df['A'], or df.A, etc), the resulting vector is automatically converted to a Series instead of a single-column DataFrame. However, I am writing some functions that takes a DataFrame as an input...
https://stackoverflow.com/questions/16782323/keep-selected-column-as-dataframe-instead-of-series
python, pandas
1,369,702,132
se_31313980
stackoverflow
DATA_SCIENCE
Display Pandas groupby results for defined groups only
Display Pandas groupby results for defined groups only I have a pandas dataframe of the following basic format: tempDF = pd.DataFrame({ 'id': [12,12,12,12,45,45,45,51,51,51,51,51,51,76,76,76,91,91,91,91], 'measure': [3.2,4.2,6.8,5.6,3.1,4.8,8.8,3.0,1.9,2.1,2.4,3.5,4.2,5.2,4.3,3.6,5.2,7.1,6.5,7....
https://stackoverflow.com/questions/31313980/display-pandas-groupby-results-for-defined-groups-only
python, pandas, group-by, python-3.4
1,436,435,364
se_79899547
stackoverflow
DATA_SCIENCE
Flatten multindex column in a pipe in pandas
Flatten multindex column in a pipe in pandas Suppose I have the following DataFrame: arrays = [[1, 1, 2, 2], ["red", "blue", "red", "blue"]] ix = pd.MultiIndex.from_arrays(arrays, names=("number", "color")) df = pd.DataFrame([[10, 20, 30, 40], [50, 60, 70, 80]], columns=ix) df I would like to flatten the MultiIndex ...
https://stackoverflow.com/questions/79899547/flatten-multindex-column-in-a-pipe-in-pandas
python, pandas, dataframe
1,772,468,204
se_75812151
stackoverflow
DATA_SCIENCE
How to overcome Athena/glue varchar limit when using COPY command from parquet
How to overcome Athena/glue varchar limit when using COPY command from parquet I think I have a very peculiar case. I have been trying different approaches, but nothing worked yet. My goal: write a pandas df to redshift My data frame: 10 columns, 2 of which have data in json format and are pretty long (more than 65535...
https://stackoverflow.com/questions/75812151/how-to-overcome-athena-glue-varchar-limit-when-using-copy-command-from-parquet
pandas, amazon-redshift, aws-glue, parquet, amazon-athena
1,679,487,382
se_79897082
stackoverflow
DATA_SCIENCE
Is there a possibility to ignore case sensitivity?
Is there a possibility to ignore case sensitivity? I have a data logger that creates columns in its data sets with names that use both uppercase and lowercase letters, e.g., "SampleTime" and "SensorData". After a firmware update, the columns are now created with the same names, but only with uppercase letters, such as...
https://stackoverflow.com/questions/79897082/is-there-a-possibility-to-ignore-case-sensitivity
python, pandas, dataframe, case-insensitive
1,772,113,698
se_79902534
stackoverflow
DATA_SCIENCE
Update Pandas Series with Multiindex
Update Pandas Series with Multiindex I am trying to update a subset of a multiindexed series with a series having the same index (see MWE below). I have a method which does not work even though it should imho. I have a slow method that does work. And I have a fast method that does work, but throws a warning. I'd like ...
https://stackoverflow.com/questions/79902534/update-pandas-series-with-multiindex
python, pandas, dataframe, series, multi-index
1,772,831,363
se_79940550
stackoverflow
DATA_SCIENCE
Google Colab Python Pandas Styled Dataframe_image Font Use
Google Colab Python Pandas Styled Dataframe_image Font Use When I display the styled dataframe table in the cell output, they look just how I want, but when I convert them to images, a different font is used. I think I understand why, that my machine has the font, but the headless bowser that is creating the table in ...
https://stackoverflow.com/questions/79940550/google-colab-python-pandas-styled-dataframe-image-font-use
python, pandas, dataframe, fonts, google-colaboratory
1,778,678,797
se_25571882
stackoverflow
DATA_SCIENCE
pandas columns correlation with statistical significance
pandas columns correlation with statistical significance What is the best way, given a pandas dataframe, df, to get the correlation between its columns df.1 and df.2? I do not want the output to count rows with NaN, which pandas built-in correlation does. But I also want it to output a pvalue or a standard error, wh...
https://stackoverflow.com/questions/25571882/pandas-columns-correlation-with-statistical-significance
python, pandas, scipy, correlation
1,409,327,691
se_79938420
stackoverflow
DATA_SCIENCE
SettingWithCopyWarning when filtering and updating a Pandas DataFrame?
SettingWithCopyWarning when filtering and updating a Pandas DataFrame? I am trying to update values in a specific column of a Pandas DataFrame after filtering it, but I keep getting a SettingWithCopyWarning. While the code sometimes works, I want to know the "best practice" way to avoid this warning and ensure I'm not...
https://stackoverflow.com/questions/79938420/settingwithcopywarning-when-filtering-and-updating-a-pandas-dataframe
python, pandas
1,778,282,428
se_20109391
stackoverflow
DATA_SCIENCE
How to make good reproducible pandas examples
How to make good reproducible pandas examples Having spent a decent amount of time watching both the r and pandas tags on SO, the impression that I get is that pandas questions are less likely to contain reproducible data. This is something that the R community has been pretty good about encouraging, and thanks to gui...
https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples
python, pandas
1,384,990,299
se_78889888
stackoverflow
DATA_SCIENCE
How to create a parameterized query for pandas with a dynamic table name that avoids SQL injection?
How to create a parameterized query for pandas with a dynamic table name that avoids SQL injection? I am using SQL Server, pandas, and pyodbc. I am trying to make a function that can take a column name, table name, another column name (for a GUID-type column), and a GUID value and run a SQL statement like: SELECT colu...
https://stackoverflow.com/questions/78889888/how-to-create-a-parameterized-query-for-pandas-with-a-dynamic-table-name-that-av
python, sql-server, pandas, pyodbc
1,724,104,037
se_79807638
stackoverflow
DATA_SCIENCE
Slice a Pandas dataframe at specific index points
Slice a Pandas dataframe at specific index points I have below Pandas dataframe import pandas as pd data = pd.DataFrame({'x1':range(10, 18), # Create pandas DataFrame 'x2':['a', 'b', 'b', 'c', 'd', 'a', 'b', 'd'], 'x3':range(27, 19, - 1), 'x4':['x', 'z...
https://stackoverflow.com/questions/79807638/slice-a-pandas-dataframe-at-specific-index-points
python, pandas, dataframe
1,762,157,307
se_78501868
stackoverflow
DATA_SCIENCE
Define data type in creating custom function
Define data type in creating custom function I have below custom function import pandas as pd def MyFn(DF : pd.DataFrame) -> float : return DF['Col_A'].values[1] - DF['Col_B'].values[1] However I want to force user to supply a dataframe with 2 columns and having column names as 'Col_A' and 'Col_B'. How can I go abo...
https://stackoverflow.com/questions/78501868/define-data-type-in-creating-custom-function
python, pandas
1,716,103,517
se_79938428
stackoverflow
DATA_SCIENCE
Add character to value in Pandas Dataframe column if value is specific length
Add character to value in Pandas Dataframe column if value is specific length I am trying to reformat the values in a dataframe column for a person's height from, for example, 5'8" to 5 Feet 8 Inches and I figure that I can at least replace the apostrophe and double quotes first with " Feet" and " "Inches". So, I hav...
https://stackoverflow.com/questions/79938428/add-character-to-value-in-pandas-dataframe-column-if-value-is-specific-length
python, pandas, dataframe, numpy
1,778,284,706
se_79938182
stackoverflow
DATA_SCIENCE
Inconsistent nonzero: pandas sparse and dense arrays
Inconsistent nonzero: pandas sparse and dense arrays Original My understanding is that sparse and dense matrices store the same information, but in a different internal format. I have a sparse matrix of mostly False values: (Pdb) x [False, False, False, False, False, False, False, False, False, False, False, False, Fa...
https://stackoverflow.com/questions/79938182/inconsistent-nonzero-pandas-sparse-and-dense-arrays
python, pandas
1,778,248,910
se_79937514
stackoverflow
DATA_SCIENCE
Plotly creating multiple duplicate graphs
Plotly creating multiple duplicate graphs Minimum reproducable example: iso country year gdp_per_c Scenario AFG Afghanistan 2030 0.3890 SSP1-2.6 AFG Afghanistan 2040 0.6465 SSP1-2.6 AFG Afghanistan 2030 0.2106 SSP2-4.5 AFG Afghanistan 2040 0.3635 SSP2-4.5 I am using t...
https://stackoverflow.com/questions/79937514/plotly-creating-multiple-duplicate-graphs
python, pandas, plotly
1,778,150,941
se_68997443
stackoverflow
DATA_SCIENCE
Calculate age in day, month and year from birth date and a specific day using python
Calculate age in day, month and year from birth date and a specific day using python I have dataframe of medical services performed in a city. I would like to get the age of the individuals served based on the two columns: the birth date column and the service date column. I am using python (google colaboratory). my d...
https://stackoverflow.com/questions/68997443/calculate-age-in-day-month-and-year-from-birth-date-and-a-specific-day-using-py
python, pandas, datetime, calculated-columns
1,630,407,458
se_76667941
stackoverflow
DATA_SCIENCE
How to track changes of two non-similar dataframes?
How to track changes of two non-similar dataframes? I have these two dataframes : col1 col2 a foo NaN b qux 2.0 c bar NaN d baz 4.0 col1 col2 a foo NaN c NaN 3.0 d baz 5.0 e xxx 6.0 My expected output is a python dictionnary exactly like below : out_dict = { "b": "deleted", #becaus...
https://stackoverflow.com/questions/76667941/how-to-track-changes-of-two-non-similar-dataframes
python, pandas, dataframe
1,689,145,762
se_76831180
stackoverflow
DATA_SCIENCE
CSV Data Cleaning with Python/Pandas
CSV Data Cleaning with Python/Pandas Need help with the below scenario: Excel data in csv source file is like: I want to clean and rearrange it so that it looks like: Adding the messy and cleaned dicts as requested import pandas as pd file_path = r"C:\Users\abcd\OneDrive\Documents" messy_data_file_name = 'messy_data...
https://stackoverflow.com/questions/76831180/csv-data-cleaning-with-python-pandas
python-3.x, pandas, csv, data-cleaning
1,691,091,617
se_71035693
stackoverflow
DATA_SCIENCE
Is it possible to put this np.where function in a loop?
Is it possible to put this np.where function in a loop? I'm trying to move all values in the data frame that contains Applicant Age data (there is only one Applicant Age value per row) into a new column applicant_age, but there are 17 columns that I have to iterate over to find them - the data is all mixed up at the m...
https://stackoverflow.com/questions/71035693/is-it-possible-to-put-this-np-where-function-in-a-loop
python, pandas, numpy
1,644,330,907
se_79933644
stackoverflow
DATA_SCIENCE
Have pandas warn when operation causes exception on some rows, but continue processing valid rows
Have pandas warn when operation causes exception on some rows, but continue processing valid rows We have a python script that (in large part) manipulates data with pandas. Recently, a small amount of input data was malformed and the whole thing crashed when an exception was thrown within `pd.apply` We need some non-s...
https://stackoverflow.com/questions/79933644/have-pandas-warn-when-operation-causes-exception-on-some-rows-but-continue-proc
python, pandas
1,777,464,446
se_48223370
stackoverflow
DATA_SCIENCE
Python Plotly: autosize table plot
Python Plotly: autosize table plot I'm plotting tables of different sizes with Plotly that I want to export as an image. However the size of the plot doesn't automatically scale with the table size resulting in only part of the table displayed in the image (or lot's of white space if I set the plot size too large). I ...
https://stackoverflow.com/questions/48223370/python-plotly-autosize-table-plot
python, pandas, plotly
1,515,749,964
se_79925505
stackoverflow
DATA_SCIENCE
Extracting information from dictionaries in Pandas
Extracting information from dictionaries in Pandas I have a dataframe: import pandas as pd d1 = str([{"Alice": "1/2"}, {"Bob": "3/11"}, {"Charlotte": "5/2"}]) d2 = str([{"Bob": "2/7"}, {"Daniel": "4/5"}]) d3 = str([{"Emily": "12/5"}]) d4 = str([{"Bob": "4/11"}, {"Victor": "2/2"}, {"Bob": "5/6"}]) df = pd.DataFrame([d...
https://stackoverflow.com/questions/79925505/extracting-information-from-dictionaries-in-pandas
python, pandas
1,776,183,941
se_50346143
stackoverflow
DATA_SCIENCE
Unable to implement Holt-Winters Method using statsmodels library
Unable to implement Holt-Winters Method using statsmodels library I have a one month data that is on a daily basis.It captures cpu utilization data everyday.I want to produce some forecast results.I have split the data into two parts train- which takes first 15 days and test which takes the last 16 days and on this I ...
https://stackoverflow.com/questions/50346143/unable-to-implement-holt-winters-method-using-statsmodels-library
python, pandas, statsmodels, forecasting, holtwinters
1,526,374,779
se_37439014
stackoverflow
DATA_SCIENCE
Possible for pandas dataframe to be rendered in a new window?
Possible for pandas dataframe to be rendered in a new window? We all love using pandas and how the dataframe shows us a snippet of the data. However within the ipython notebook, sometimes it is difficult to view all the data especially if it contains too many columns. Was just wondering if there is an option to view ...
https://stackoverflow.com/questions/37439014/possible-for-pandas-dataframe-to-be-rendered-in-a-new-window
python, pandas
1,464,183,693
se_46636080
stackoverflow
DATA_SCIENCE
Merge rows within a group together
Merge rows within a group together I have a pandas DataFrame where some pairs of rows have the same ID but different name. What I want is to reduce the rows to one row per ID and display both of their names. INPUT: ID NAME AGE 149 Bob 32 150 Tom 53 150 Roberts 53 151 Pamela 28 152 Andrew 23 ...
https://stackoverflow.com/questions/46636080/merge-rows-within-a-group-together
python, pandas, dataframe, group-by
1,507,496,874