289,205 questions
0
votes
0
answers
19
views
Missing values in olive oil dataset
I have a dataset of olive oil samples and the goal of creating a classification model for oil quality. I'm having trouble deciding how to deal with missing data. have a look at the data here if you ...
0
votes
1
answer
41
views
Custom Shaping in pandas for Excel Output
I have a dataset with world population (For clarity, countries are limmited to Brazil, Canada, Denmark):
import pandas as pd
world = pd.read_csv("../data/worldstats.csv")
cond = world[&...
0
votes
1
answer
48
views
Python Pandas.read_csv header and index column not lining up
I have a bunch of csv files read from a teensy adc onto an SD card and am trying to extract them to be able to do some basic stats over each row.
I have tried everything I can think of to try and fix ...
-1
votes
0
answers
52
views
open_exel_file — getting "TypeError: unicode error"
I'm new to learning Python, and when I try to open_exel_file, I get this error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Code
...
-7
votes
0
answers
44
views
> AttributeError: 'float' object has no attribute 'items' [closed]
I've read many posts on this site but not yet posted so I apologize for first-timer mistakes.
I'm writing a class that has created a pandas dataframe to store information about an instance of the ...
-1
votes
1
answer
31
views
Run a dataframe of URLs through a function - Python
I am trying to use a dataframe that contains a bunch of URLs and run each individual URL through a function. Note: the function works perfectly if called with a single URL i.e. myfunction(https://www....
0
votes
0
answers
27
views
best way to extend/subclass pandas.DataFrame
I've written a package to work with energy-related timeseries. At its center is a class (PfLine) that is essentially a wrapper around pandas.DataFrame, and it implements various methods and properties ...
0
votes
0
answers
42
views
Why does `groupby` return fewer rows than the number of unique rows after removing duplicates? [duplicate]
I'm working with a DataFrame df and trying to understand why the result of a groupby operation has fewer rows than expected. Here's what I did:
columnas = ["description", "surface_total&...
0
votes
0
answers
42
views
Apply float styling to specific rows in pandas dataframe
I've created a large dataframe with a smaller dataframe that represents a summary of some calculations run on the larger dataframe. This will find certain percentages, max/min of some columns, etc. I'...
0
votes
1
answer
51
views
Why does pd.to_datetime('2025175', format='%Y%W%w') and pd.Timestamp.fromisocalendar(2025, 17, 5) gives different output? [duplicate]
Why does pd.to_datetime('2025175', format='%Y%W%w') and pd.Timestamp.fromisocalendar(2025, 17, 5) gives different output?
I expected to obtain Timestamp('2025-04-25 00:00:00') for both cases.
But the ...
0
votes
2
answers
52
views
Splitting the time dimension of nc data using xarray
Now I have a timelonlat 3D data where time is recorded as year, month and day. I need to split time in the form of year*month+day. So that the data becomes 4 dimensional. How should I do this?
I have ...
-3
votes
0
answers
65
views
When trying to index from a series, why it just showed one element instead of one row?
I am working on a python practice.
I am trying to filter out which occupation has the lowest average sleeping duration from data csv. Here is example code.
import pandas as pd
sleep_data = pd.read_csv(...
1
vote
1
answer
46
views
In Pandas, assign the last value in a group to the next group by index value?
I have a question very similar to this one but 1) I want this to work for a Series also and 2) I don't have a column representing my grouping values; the values are in the index.
Imagine I have a ...
-1
votes
0
answers
25
views
Save pandas dataframe in postgres database
Is there a way to save pandas dataframe as a value in a postgres database column? Let's say the column was named df_metadata
The use case is that we want to save the dataframe to later run statistical ...
2
votes
2
answers
63
views
Pandas: Fill in missing values with an empty numpy array
I have a Pandas Dataframe that I derive from a process like this:
df1 = pd.DataFrame({'c1':['A','B','C','D','E'],'c2':[1,2,3,4,5]})
df2 = pd.DataFrame({'c1':['A','B','C'],'c2':[1,2,3],'c3': [np.array((...