All Questions
Tagged with dataframes or dataframe
148,706 questions
1
vote
3
answers
73
views
Move time 1 hour back on range of rows in pandas
I have a dataset with a 'Time' column; for 2 dates the time is incorrect and I need to move it back by 1 hour.
This is what my dataframe looks like:
Date Time
05.01.2026 17:00
06.01.2026 ...
0
votes
1
answer
74
views
Understanding list-like functions in transform and apply command in pandas
TLDR;
I'm trying to understand why list-like methods in dataframes behave the same as the list-like methods in Series.
Basically, in Series, if you use apply or transform on list-like methods, they ...
-1
votes
0
answers
61
views
ETL on a Overcomplex Data Structure with pandas and pyspark
The question is: are the proposed methods for flattening a given dataframe efficient enough, or could they be further refined?
An example of a pandas input dataframe columns (it is a given, cannot be ...
0
votes
0
answers
100
views
Get filepath using Flet in python
I am using Flet 0.80.4 with Python 3.11.
The user should be able to upload a file via a button. I want to process this file with Polars or Pandas. I found some examples of how to handle file uploads, ...
4
votes
0
answers
126
views
Prevent casting numeric types to string when replacing certain values
I have the following data:
import polars as pl
dat = pl.DataFrame({"x": ["a", "b"]})
and I have a function where the user can replace some values in x. I would like to ...
2
votes
3
answers
81
views
Creating new columns derived from existing column in pandas dataframe [duplicate]
I work with Pandas, which is the project I'm currently working on.
This is the dataframe:
property_type place_with_parent_names region lat-lon area_m2 price_usd lat lon
0 apartment |...
3
votes
1
answer
59
views
How to get polars.LazyFrame.pivot work with multiple columns?
With a DataFrame, I can easily pivot this table
id
subject
exam
grade
1
maths
theory
10
1
maths
practice
12
3
physics
theory
15
Into this table
id
{"maths","theory"}
{"maths&...
Advice
0
votes
5
replies
69
views
Numpy axis rules
I am a Python developer, but I don't understand one thing: what are the numpy axis? Sometimes, when I use Sklearn, I have errors about axis. And I need explanations about values and reshape functions.
2
votes
2
answers
99
views
Using pivot with Pandas [duplicate]
I have a Pandas dataframe which I need to both restructure, and modify slightly. I have a solution that works, but is naive and slow--I will post that below. Essentially, I have spatial data that I ...
2
votes
1
answer
90
views
ChainedAssignmentError when adding a conditional to a pandas dataframe
I keep getting a ChainedAssignmentError when adding a conditional to my code. In this basic example I am checking to see if column "one" is an "e" and if so then set the "...
5
votes
3
answers
152
views
Pandas rename() not working on MultiIndex columns with tuples
I am working with a pandas DataFrame that has a MultiIndex (two levels) for columns. I am trying to rename specific columns using a dictionary of tuples, but the column names remain unchanged.
import ...
3
votes
1
answer
132
views
SettingWithCopyWarning: DataFrame.iterrows using .loc - pandas views vs copy [duplicate]
(Similar questions with this warning always wind down to the same thing described in the docs; use .loc however I'm already doing that and the line that should be in the error to use .loc is hence ...
3
votes
1
answer
198
views
How to run multiple statistical distributions across all possible combinations of values in a column & assign the minimum to a new column?
I am attempting to construct bins for a large dataset, such that the subset of data within each bin conforms well to an exponential distribution. The basic structure of the data looks like this, but ...
2
votes
1
answer
110
views
Polars to_date conversion from str to date fails with proper format
I have a polars dataframe with a date column I've built with the format %YW%W. I want to convert the column to a date, so I wrote the following snippet:
agg_pivoted_df = pivoted_df.with_columns([
...
-3
votes
0
answers
77
views
How can I retrieve rows from a DataFrame where a column meets certain conditions? [duplicate]
How can I select rows from a DataFrame based on values in some column in Pandas? Should I use the groupby method? If so I'm not sure how to implement the condition. Also how to create nodes based on ...