我有一个如下所示的数据框:
我意识到func TableHandler(mux http.ServeMux) {
mux.HandleFunc("/gpdp/v1/prices/", func(w http.ResponseWriter, r *http.Request)
log.Println("request for prices: ", r.Method, r.Body)
...}
列可以通过 public void GetFiles()
{
ds.Clear();
this.dgArchivos.DataSource = null;
this.dgArchivos.Rows.Clear();
this.dgArchivos.Refresh();
filesPath = Clases.Utilerias.RutaArchivos;
this.lblFilePath.Text = filesPath;
DirectoryInfo di = new DirectoryInfo(filesPath);
var archivos = di.GetFiles("*.pdf");
DataRow dr;
//PASO 1 -- Cargamos el XML
string rutaConfig = string.Format(@"{0}\{1}", filesPath, "config.xml");
FileInfo fi = new FileInfo(rutaConfig);
if (fi.Exists)
{
ds.ReadXml(rutaConfig);
}
//PASO 2 -- Agregamos los archivos que no existan en el xml
foreach (var archivo in archivos)
{
if (!ExisteArchivoEnTabla(archivo.Name)) //antes de cargar los archivos a la tabla es necesario revisar si ya existe en ella
{
dr = ds.Tables[0].NewRow();
dr["FileName"] = archivo.Name;
ds.Tables[0].Rows.Add(dr);
}
}
this.dgArchivos.DataSource = ds.Tables[0];
if (dgArchivos.Rows.Count > 0)
{
int Total = (dgArchivos.Rows[0].Cells.Count - 2);
dgArchivos.Columns[Total].DefaultCellStyle.NullValue = "Preview";
}
this.getFRunning = false;
}
的函数生成
确切地说:using System;
using System.IO;
using System.Security.Permissions;
using ScanScraping.App;
namespace ScanScraping.Clases
{
public class FileWatcher
{
public static frmProcessFile frm;
public FileWatcher(frmProcessFile process)
{
frm = process;
Run();
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public static void Run()
{
// Create a new FileSystemWatcher and set its properties.
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = Clases.Utilerias.RutaArchivos;
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.pdf";
// Add event handlers.
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnDeleted);
// Begin watching.
watcher.EnableRaisingEvents = true;
// Wait for the user to quit the program.
}
// Define the event handlers.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Specify what is done when a file is changed, created, or deleted.
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
frm.formPadre.xmlCreateOrUpdate();
frm.GetFiles();
}
public static void OnDeleted(object source, FileSystemEventArgs e)
{
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
string[] file = e.FullPath.Split('\\');
string fName = file[file.Length - 1];
frm.updateXML(fName);
frm.GetFiles();
}
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
frm.formPadre.xmlCreateOrUpdate();
frm.GetFiles();
}
}
}
//rdo-nav-card-asset/div[contains(@class,'panel') and contains(@class,'highlight')]/div[contains(@class,'panel-heading')]/div[contains(@class,'panel-title')]
列中有day_charge
个值,如何使用上述函数填充day_mins
值?
答案 0 :(得分:3)
由于您的列始终为day_mins * .17
,因此在您的情况下,替换整列可能更容易,更快:
df['day_charge'] = df['day_mins'] * 0.17
但@jpp的解决方案实际上解决了如何使用给定函数填充NaN
的问题。
答案 1 :(得分:2)
您可以使用pd.Series.fillna
填写缺失值:
{{1}}