Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pytrends/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,21 @@ def interest_over_time(self):
if 'isPartial' in df:
# make other dataframe from isPartial key data
# split list columns into seperate ones, remove brackets and split on comma
df = df.fillna(False)
# Infer object types before filling missing values
df = df.infer_objects(copy=False)

# Handle missing values column by column to avoid downcasting
for col in df.columns:
if df[col].dtype == 'object':
# Handle missing values in object-type columns (strings or mixed types)
df[col] = df[col].fillna("Unknown") # Replace NaNs with "Unknown" for strings
elif df[col].dtype in ['int64', 'float64']:
# Handle missing numeric values
df[col] = df[col].fillna(0) # Replace NaNs with 0 for numeric data
elif df[col].dtype == 'bool':
# Handle missing boolean values
df[col] = df[col].fillna(False) # Replace NaNs with False for booleans

result_df2 = df['isPartial'].apply(lambda x: pd.Series(
str(x).replace('[', '').replace(']', '').split(',')))
result_df2.columns = ['isPartial']
Expand Down